我試圖從Person
表中獲取多列。但我似乎只能在這裏獲得一個物業(Address
)。爲什麼我不能在這裏做多個選擇?無法對列進行多個選擇
largeThings = DbContext.Set<Things>()
.Where(ep => ep.CreatedDate > dateTimeYesterday)
.Include(ep => ep.People
.Select(p => p.Person)
.Select(p => p.Address)).ToList();
我試圖用一個匿名對象,如:
largeThings= DbContext.Set<Episode>()
.Where(ep => ep.CreatedDate > dateTimeYesterday)
.Include(ep => ep.People
.Select(p => p.Person)
.Select(p => new { p.Address, p.FirstName })).ToList();
但是,這將引發一個導航屬性錯誤。有沒有其他方法可以在這裏選擇多列?
我希望能夠從Person
表中獲得FirstName
和Address
。
因爲你只選擇地址你得到的地址。請在第二次嘗試中顯示確切的錯誤 –
在第一個示例中。我想添加一個select來從'Person'獲得一列。如果我添加另一個Select,它會更深入到我不想要的對象中。 –
'包含路徑表達式必須引用在類型上定義的導航屬性。對參考導航屬性使用虛線路徑,對集合導航屬性使用Select操作符。' –