![](/img/trans.png)
[英]How do i get specific columns from a thenInclude using Include with Multiple Levels of Properties
[英]How do I use the .Include method to get multiple related properties (of different types) from database?
我想從我的數據庫中名為“約會”的表中獲取信息,並獲取與每個約會相關的所有“治療”和“用戶”。 我嘗試使用System.Data.Entity
中的.Include
,但只能讓它在我需要它們的地方帶來一個相關的屬性。
using System.Data.Entity;
public override List<Appointment> GetAll()
{
using (DB = new DBModel())
{ return DB.Appointments.Include(a => a.Treatments).ToList(); }
}
有沒有辦法可以使用 include 來帶來超過 1 個相關的屬性? 如果不是,我怎么能帶來超過 1 個相關的財產呢?
您應該能夠像這樣鏈接包含
return DB.Appointments
.Include(a => a.Treatments)
.Include(a => a.Users)
.ToList();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.