Now that is more like it :) It looks really cool... Unfortunately my project is currently bound to .NET 2.0, so I can't use lambda expressions yet.
But if I'm to understand you correctly, it can't be done using the Criteria API? On 11 Mar., 13:32, Fabio Maulo <[email protected]> wrote: > Projections.Property("e.Cualquier.Cosa.Com.Ar") type-safe not for sure, so > far... probably it will be type-safe in the > futurehttp://code.google.com/p/nhlambdaextensions/ > > 2009/3/11 TigerShark <[email protected]> > > > > > > > How can I return a component type of a mapped class using the Criteria > > API. I guess I have to use a projection, but if I project on the > > component I get an exception telling me it doesn't map to a single > > property. > > > I can do it using HQL though, but I'd rather use the Criteria API if > > possible. > > > In HQL I do like this: > > > var criteria = session.CreateQuery("select e.Component from Entity e > > where e.Id = :id"); > > criteria.SetParameter("id", id); > > return criteria.UniqueResult<ComponentType>(); > > > What I'd like to do is something like this with the Criteria API: > > > var criteria = session.CreateCriteria(typeof(Entity), "e"); > > criteria.Add(Restrictions.IdEq(id)); > > criteria.SetProjection(Projections.Property("e.Component"); > > return criteria.UniqueResult<ComponentType>(); > > > Even though the second example is more verbose, I believe it's safer > > in regards of type-safety (and spelling). > > -- > Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
