我有兩個表,提交和符號。 提交有單個條目和記號有多個條目通過AppID鏈接提交。Linq to Entities查詢 -
我試圖完成的是將提交的內容提交給定的日期範圍,並提交最新的符號。
我已經設法獲得所有的數據;然而,它是複製每個提交記錄爲每個符號提交。
這是我目前的代碼。任何人都可以幫我解決這個問題嗎?
var query = (from s in db.Submissions
from n in db.notations
from d in db.DCodes
where s.AppID == (int) n.AppID
&& s.DCode == d.DCode1
&& s.received >= dts
&& s.received <= dte
select new ApplicationTrackingSystem.customModels.Export
{
AppID = s.AppID,
received = s.received,
//dcode = s.DCode,
dcode = d.description,
firstName = s.firstName,
middleName = s.middleName,
lastName = s.lastName,
street = s.street,
city = s.city,
state = s.state,
zip = s.zip,
position = s.position,
hearAbout = s.hearAbout,
referredby = s.referredBy,
email = s.email,
commentID = n.commentID,
commentDate = n.commentDate,
user = n.userID,
comment = n.comment
}).ToList();
它如何只選擇「最近的」符號? –