0
我有MainClass
和ChildData
。獲取外貿信息
我需要得到ChildData
給出MainClass
。
MainClass
有一個名爲ChildClassProperty
的屬性。 ChildData
已獲得ForeignKey至MainClass
。我如何獲得使用LINQ的ChildData
?
至今:
using (var ctx = Csla.Data.ObjectContextManager<DB.Data.Entities>.GetManager(Model.EntitiesDatabase.Name))
{
var xxx = from a in ctx.ObjectContext.ChildData where a...
}
您使用的EF? – Miller
是使用EF 4.5 –
您需要爲模型中的關係添加導航。並在LINQ中使用INCLUDE()。這可能http://weblogs.asp.net/manavi/archive/2011/05/17/associations-in-ef-4-1-code-first-part-6-many-valued-associations.aspx幫助你 – Miller