C# Lambda expressions and NHibernate

前端 未结 5 1150
遇见更好的自我
遇见更好的自我 2020-12-24 08:57

I\'m a newbie in the great world of NHibernate. I\'m using version 2.0.1.GA. Here\'s my question. I have a table Cars with column Manufacturer(nvarchar(50

相关标签:
5条回答
  • 2020-12-24 09:02

    You could probably do this with NHibernate.Linq. It is in a usable form, but still a ways from being complete. Its currently living inside nhcontrib, the only way to get it is to pull it out of svn here https://nhcontrib.svn.sourceforge.net/svnroot/nhcontrib/trunk/src/NHibernate.Linq/

    0 讨论(0)
  • 2020-12-24 09:08

    Like Google Ninja said, you can do it with NHibernate.Linq. The query would then be:

    session.Linq<Car>.Where(c => c.Manufacturer == "Mercedes").ToList()

    If someone ends up here and is using NH3.0 the syntax is just a tad different (thanks to Michael Mrozek and Mike for the suggestion):

    session.Query<Car>.Where(c => c.Manufacturer == "Mercedes").ToList()

    I've used a binary that came bundled with fluent-nhibernate that works with 2.0GA (I think, not sure about the particular revision).

    0 讨论(0)
  • 2020-12-24 09:14

    You can find what you are looking for here (blog entry) or here (google repository)

    0 讨论(0)
  • 2020-12-24 09:19

    Look at this question here. Someone had the same worry, and from I can gather, NHibernate.Linq is well alive.

    0 讨论(0)
  • 2020-12-24 09:25

    If you don't want to use Linq to NHibernate yet, there's a couple of alternatives to get strongly type Criteria queries:

    • http://bugsquash.blogspot.com/2008/03/strongly-typed-nhibernate-criteria-with.html
    • http://www.kowitz.net/archive/2008/08/17/what-would-nhibernate-icriteria-look-like-in-.net-3.5.aspx
    0 讨论(0)
提交回复
热议问题