Added some more fields to the query, now get an issue: String is not a
valid date time, It again looks like it is not mapping properly, am I
missing something here?

 DetachedCriteria criteria = DetachedCriteria.For(typeof
(Model.Course), "course")
                    .CreateAlias("course.SubjectArea", "subjectArea")
                    .CreateCriteria("course.Institution",
"institution")
                    .Add(Expression.Eq("subjectArea.WeeklyFeeType",
true))
                    .SetProjection(Projections.ProjectionList()
                                           
.Add(Projections.Property("institution.Id"),
"InstitutionId")
                                           
.Add(Projections.Property("institution.Name"),
"InstitutionName")
                                           
.Add(Projections.Property("course.Id"),
"CourseId")
                                           
.Add(Projections.Property("course.Title"),
"CourseTitle")
                                           .Add(Projections.Constant(0),
"SemesterId")
                                           
.Add(Projections.Constant(string.Empty),
"SemesterTitle")
                                           .Add(Projections.Constant(startDate),
"StartDate")
                                           
.Add(Projections.Constant(startDate.AddDays(weeks
* 7)), "EndDate")
                                           .Add(Projections.Constant(weeks),
"Weeks")
                                           .Add(Projections.Constant(""),
"DurationDescription")
                                           
.Add(Projections.Constant(Convert.ToDecimal(0)),
"Fee")
                    )
                    .SetResultTransformer(Transformers.AliasToBean(typeof
(CourseDetail)));



On Sep 17, 11:26 am, codemonkey <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have the following query
>
> DetachedCriteria criteria = DetachedCriteria.For(typeof
> (Model.Course), "course")
>                     .CreateAlias("course.SubjectArea", "subjectArea")
>                     .CreateCriteria("course.Institution",
> "institution")
>                     .Add(Expression.Eq("subjectArea.WeeklyFeeType",
> true))
>                     .SetProjection(Projections.ProjectionList()
>                                            
> .Add(Projections.Property("institution.Id"),
> "InstitutionId")
>                                            
> .Add(Projections.Property("institution.Name"),
> "InstitutionName")
>                                            
> .Add(Projections.Property("course.Id"),
> "CourseId")
>                                            
> .Add(Projections.Property("course.Title"),
> "CourseTitle")
>                                            .Add(Projections.Constant(0),
> "SemesterId")
>                                            
> .Add(Projections.Constant(string.Empty),
> "SemesterTitle")
>                                            
> .Add(Projections.Constant(startDate),
> "StartDate")
>                                            
> .Add(Projections.Constant(startDate.AddDays(weeks
> * 7)), "EndDate")
>                     )
>                     .SetResultTransformer(Transformers.AliasToBean(typeof
> (CourseDetail)));
>
> If is mapping to my DTO from my query, wierd thing is it is failing,
> if you look at the SQL it is not setting the correct value for the
> Expression, it is this WHERE subjectare1_.WeeklyFeeType = @p4, and p4
> = A date that was passed in.
>
> Why is it not mapping across corectly, I am using NHibernate 2.0
>
> exec sp_executesql N'SELECT TOP 10 y0_, y1_, y2_, y3_, y4_, y5_, y6_,
> y7_ FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__)
> as row, query.y0_, query.y1_, query.y2_, query.y3_, query.y4_,
> query.y5_, query.y6_, query.y7_, query.__hibernate_sort_expr_0__ FROM
> (SELECT institutio2_.ID as y0_, institutio2_.Name as y1_, this_.ID as
> y2_, this_.Title as y3_, @p0 as y4_, @p1 as y5_, @p2 as y6_, @p3 as
> y7_, CURRENT_TIMESTAMP as __hibernate_sort_expr_0__ FROM
> Phoenix2008.dbo.Courses this_ inner join Phoenix2008.dbo.Institutions
> institutio2_ on this_.InstitutionID=institutio2_.ID inner join
> Phoenix2008.dbo.SubjectAreas subjectare1_ on
> this_.SubjectAreaID=subjectare1_.ID WHERE subjectare1_.WeeklyFeeType =
> @p4) query ) page WHERE page.row > 0 ORDER BY
> __hibernate_sort_expr_0__',N'@p0 bit,@p1 int,@p2 nvarchar(4000),@p3
> datetime,@p4 datetime',@p0=1,@p1=0,@p2=N'',@p3='Sep 17 2008
> 10:20:53:707AM',@p4='Oct 22 2008 10:20:53:707AM'
>
> Cheers
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to