0
首先,我是實體框架等新手,試圖弄清楚一些事情。我有這樣一個模型:實體框架虛擬ICollection如何查詢
public class EventInstance {
[Column("EVENT_INSTANCE_ID")]
public int EventInstanceID { get; set; }
[Column("CUSTOMER_ID")]
public int CustomerID { get; set; }
[Column("EVENT_ID")]
public int EventID { get; set; }
[Column("START_DATE_TIME")]
public System.DateTime StartDateTime { get; set; }
public virtual Event Event { get; set; }
}
我需要在一個表叫EventTimeEventInstances訪問屬性,但不包括在該模型中,這表。我有兩個問題。
如果我添加:
public virtual ICollection<EventTimeEventInstance> EventTimeInstances { get; set; }
意志影響我們其他的應用領域?
其次,如何訪問從ICollection的財產在查詢這樣的:
public IQueryable<EventInstance> GetInstances(int scheduleID) {
// only returning instances that are 3 months back
DateTime dateRange = DateTime.Now.AddDays(-180);
return EventDBContext.EventInstances.Where
(x => x.CustomerID == MultiTenantID && x.StartDateTime >= dateRange)
.OrderBy(x => x.StartDateTime).AsQueryable();
}
我需要能夠scheudleID添加EventTimeInstances.EventTimeID ==來此查詢。我怎樣才能做到這一點?
的工作,謝謝。 – pgtips 2014-10-28 14:06:50