3
我試圖使用LINQ/LAMBDA訪問屬性無法解析屬性(LINQ /λ)
List<Latest> latestBooks = DataContext.Session.Query<Book>().Where(x=> x.Enabled == "True").Select(x => new Latest(x.Title,x.Author)).Take(10).ToList();
但有看起來像這樣的書類中定義的另一個屬性:
public virtual string FrontEndLink { get { return string.Format("http://myurl/{0}", Filename); } }
當我嘗試這個
List<Latest> latestBooks = DataContext.Session.Query<Book>().Where(x=> x.Enabled == "True").Select(x => new Latest(x.FrontEndLink)).Take(10).ToList();
代碼休息,並給我一個錯誤:
Could not resolve property: Quote((x,) => (x.Id)),), Quote((x,) => (new Latest(x.FrontEndLink,))),), p1,)]
非常感謝喬恩的解決方案和明確的解釋... thnx –