所需SQL相當於:SQL的LINQ語法
select * from polls where (id=(select max(id) from polls where publish_at=(select max(publish_at) from polls where publish_at<='2012-08-10 00:00:00')) and status=1)
我已經試過這一點,但它給空,而應返回一行。
var qry = db.Polls.Where(p => p.id == db.Polls.Where(x => x.publish_at == db.Polls.Max(y => y.publish_at) && x.publish_at <= System.DateTime.Today).Max(x => x.id) && p.status.Equals(PollStatus.Active)).FirstOrDefault();
[什麼都有喲你嘗試過嗎?](http://WhatHaveYouTried.com) – 2012-08-09 15:00:05
雖然你只有兩個問題有不被接受的答案,但由此產生的百分比在這裏反映不佳;考慮接受其他問題中的至少一個答案。 – KeithS 2012-08-09 15:06:50
嘿謝謝keith S讓我意識到這一點和Juergen是的,我已經嘗試並更新了我的答案。在此回覆的幫助下,我們在這裏提供幫助! – user1511069 2012-08-10 10:51:55