nhlambdaextensions

NHibernate Lambda Extensions - CreateCriteria Issue

I want to convert a NHibernate CreateCriteria over to a NHLambdaExtensions criteria, but I'm getting errors that I don't know how to fix. The NHibernate criteria looks like this: var departments = DepartmentService .CreateCriteria() .CreateAlias( "Goals", "goal" ) .Add( Expression.Eq( "goal.Company.Id", companyId ) ) .A...

fluent nhibernate problem mapping char(1) type

The map. public SocialCodeMap() { Id(x => x.SocialCodeId); Map(x => x.Name); Map(x => x.Code); Map(x => x.DisplayOrder); } And the Class. public class SocialCode { public virtual Guid SocialCodeId { get; set; } public virtual string Name { get; set; } public virtual char Code { ...

NHibernate Lambdas joined ordered collection

I have a entity 'Person' a person has a collection of Friends (also Person entities) I want to get the first 10 Friends of a particular person, ordered by LatestLogin. My best effort is: public static IList<Person> GetFriends(Person person, int count) { Person personAlias = null; Person friendAlias = null; ...

NHibernate Lambda Extensions - Eager Loading a collection's assosciations

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 P...

NHLambdaExtensions: Create a Criterion object to add to ICriteria later

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...

Dividing using nhibernate results in "Could not determine member from"

This is probably something simple but I seem to be lacking some knowledge of how nhibernate works. This is my code: ICriteria query = Session.CreateCriteria(); query = query.CreateCriteria(x => x.TblProjects) .Add<TblProject>(x => x.FldCurrentFunding != 0m) .Add<TblProject>(x => x.FldCurrentFunding...

NHibernate Lambda Extensions can't use any alias query on DetachedCriteria

I'm trying to write a simple query that requires an alias as it's a Many-To-Many assocation however I can't get it to work with NH Lambda Extensions. It always gives me a compile error even though as far as I can tell it's exactly the same as the documentation and all the examples I've seen online. Works var query = DetachedCriteria.Fo...

Using an interface for a subquery in NHibernate

I normally query interfaces using DetachedCriteria in NHibernate: DetachedCriteria crit = DetachedCriteria.For<IParent>(); And this works fine. I now want to create a subquery for a child object thus: DetachedCriteria subcrit = DetachedCriteria.For<IChild>(); and add it to the criteria like this (kind of, p.Child is actually an al...

.NET - execute a lambda on another computer

Hi ;) I've recently implemented an IronRuby web service application for a client, to replace an existing C# .NET DLL. What the client forgot to mention was that in the mean time they implemented a new version of the DLL, with a new API based on lambda expressions. And made sure all calls (thousands :( ) use the new syntax. So now I need...

How to render Max(Substring) with Lambda Extensions

Hi everybody. I'm using NHibernate with Lambda Extensions. I'd like to know how to nest a Max function with a Substring. The following statement retrieves Max("invoice_id") var ret = session .CreateCriteria<Invoice>() .SetProjection(Projections.Max("invoice_id")) .UniqueResult(); but in my case the field...

How do I express “not in” using lambdas?

I'm trying to create a not in clause with the NHibernate Criteria API using NHLambdaExtensions. Reading the documentation I was able to implement the in clause by doing .Add(SqlExpression.In<Zone>(z => zoneAlias.ZoneId, new int[] { 1008, 1010 })) However, when I wrap it around SqlExpression.Not I get the error Error 5 The best ov...