What is "more OO" is only the construction of a dynamic-query. HQL is an OO-query-language as LINQ... the difference is that Linq is embedded in C#. BTW don't worry, thanks to Steve and iMeta LINQ2NH are coming soon.
2009/3/11 TigerShark <[email protected]> > > Ahh, I see... Well, no, it's not type-safe, but it feels a bit more OO > at least :) > > Regarding .NET 2.0, yeah, I'd love to make the switch, but > unfortunately it's not up to me alone... :( > All my new projects are in .NET 3.5 and this project is also converted > to VS 2008 so I'm using the .NET 3.5 compiler targeting 2.0 (gives me > auto properties and the nice var :) ) > > Furthermore we are still hosting some projects on a Windows 2000 > Server, and Microsoft has decided not to support .NET 3.5 on this > platform... Grrr! > > On 11 Mar., 13:48, Fabio Maulo <[email protected]> wrote: > > I'm not sure about if it can be done with Criteria (Criteria API in NH > are > > really different than original one). > > What I said is that Criteria API is not so "type-safe". > > > > About .NET2.0 : convert yourself!! ;) > > > > http://groups.google.com/group/nhibernate-development/browse_thread/t... > > > > 2009/3/11 TigerShark <[email protected]> > > > > > > > > > > > > > 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 > > > > -- > > Fabio Maulo > > > -- 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 -~----------~----~----~----~------~----~------~--~---
