Need to convert this sql query to nhibernate criterion language... How can I do this?
select开发者_如何学运维
*
from Feeds where Id =
(select MAX(Id) from Feeds where DataId = [VARIABLE PARAMETER])
Feed feed = _session.CreateCriteria<Feed>()
.Add(Restrictions.Eq("DataId", "[VARIABLE PARAMETER]"))
.AddOrder(new Order("_id", false))
.SetMaxResults(1)
.List<Feed>()
.FirstOrDefault();
That will result in something like:
select TOP 1 * from Feeds where DataId = ??? Order By Id desc
There should be no difference from performance point of view.
精彩评论