1
需要將此SQL查詢轉換爲nhibernate標準語言......我該怎麼做?將此SQL查詢轉換爲NHibernate標準查詢
select
*
from Feeds where Id =
(select MAX(Id) from Feeds where DataId = [VARIABLE PARAMETER])
需要將此SQL查詢轉換爲nhibernate標準語言......我該怎麼做?將此SQL查詢轉換爲NHibernate標準查詢
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();
,這將導致類似:
select TOP 1 * from Feeds where DataId = ??? Order By Id desc
應該沒有從性能的角度來看difference。