我有以下LINQ查詢。選擇()在LINQ
public List<RoleResource> GetAllRoleResources()
{
return this.GetAll<RoleResource>().ToList();
}
,我需要選擇像列1,列2和財產BColumns,這是另一個表,並具有相對於主表中只有幾列。我將如何檢索此使用。選擇()......我用了以下內容:
.Select(row => {row.Column1, row.Column2, row.BColumns}).ToList()
它不工作,也顯示錯誤。什麼是.Select()的正確語法?
您需要實例化一個匿名類型的對象。看到這個問題:http://stackoverflow.com/questions/3645494/how-can-anonymous-types-be-created-using-linq-with-lambda-syntax-基本上,你錯過了'new'。 – 2012-08-16 12:08:05