nhlambdaextensions

NHLambdaExtensions: Create a Criterion object to add to ICriteria later

落花浮王杯 提交于 2019-12-08 02:15:18
问题 My application creates a dynamically generated query at runtime based on user input by creating Criterion objects e.g: ICriterion criterion = Restrictions.Eq("Name", "John"); ...... detachedCriteriaSomewhereElse.Add(criterion); How do I do this in NHLambdaExtensions? what I really need to do is ICriterion criterion = Restrictions.Eq<Person>(p=> p.Name == "John"); but this isn't valid. Is there any way to do this? 回答1: With the NHLambdaExtensions you have the SQLExpression class that lets you

NHibernate Lambda Extensions - Eager Loading a collection's assosciations

三世轮回 提交于 2019-12-06 16:57:02
问题 I've got a Criteria Query for a social networking site. A Person object has a collection of Friends (also person objects). The query grabs the first N friends, but I also want to eager load an associated object MainProfileImage and then a subsequent associated object MediumThumbnail. I can do this in HQL easily: select friends from Person person inner join person.Friends friends inner join fetch friends.MainProfileImage image inner join fetch image.MediumThumbnail where person = :person1

NHLambdaExtensions: Create a Criterion object to add to ICriteria later

為{幸葍}努か 提交于 2019-12-06 10:28:55
My application creates a dynamically generated query at runtime based on user input by creating Criterion objects e.g: ICriterion criterion = Restrictions.Eq("Name", "John"); ...... detachedCriteriaSomewhereElse.Add(criterion); How do I do this in NHLambdaExtensions? what I really need to do is ICriterion criterion = Restrictions.Eq<Person>(p=> p.Name == "John"); but this isn't valid. Is there any way to do this? With the NHLambdaExtensions you have the SQLExpression class that lets you do the following: ICriterion criterion = SqlExpression.CriterionFor<Person>(p => p.Name == "John"); 来源:

NHibernate Lambda Extensions - Eager Loading a collection's assosciations

青春壹個敷衍的年華 提交于 2019-12-04 21:06:17
I've got a Criteria Query for a social networking site. A Person object has a collection of Friends (also person objects). The query grabs the first N friends, but I also want to eager load an associated object MainProfileImage and then a subsequent associated object MediumThumbnail. I can do this in HQL easily: select friends from Person person inner join person.Friends friends inner join fetch friends.MainProfileImage image inner join fetch image.MediumThumbnail where person = :person1 order by friends.LatestLogin desc Here's My Criteria effort. For some reason this doesn't return anything!