我有這個疑問:C# - LINQ到實體查詢屬性的價值附加到一個變量
var sole = SoleService.All().Where(c => c.Status != 250)
.Select(x => new {
ID = x.ID, Code = new {CodeName = x.Code + x.Country},
Name = x.Name
})
.Distinct()
.OrderBy(s => s.Code);
喜歡這個?給我一個錯誤。我想要結合Code
和Country
像concat字符串,所以我可以使用新的變量爲我的數據源。喜歡的東西 - 001France
P.S
我使用的是什麼,並且正在現在的問題是這樣的:
var sole = SoleService.All().Where(c => c.Status != 250)
.Select(x => new {
ID = x.ID, Code = x.Code, Name = x.Name, Country = x.Country })
.Distinct()
.OrderBy(s => s.Code);
所以我需要的是修改此查詢,以便我可以使用Code +Country
作爲一個變量。以上只是我的嘗試,我認爲會起作用。
你有什麼錯誤? – 2013-03-27 10:34:00
您能否提供您正在獲得的異常,以及SoleService.All()返回的更多上下文? – 2013-03-27 10:35:01
SoleService是一個Enumerable嗎? – 2013-03-27 10:36:03