C# Lambda expressions and NHibernate

前端 未结 5 1155
遇见更好的自我
遇见更好的自我 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:08

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

    session.Linq.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.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).

提交回复
热议问题