从另一个实体中获取 EntityCollection
我有一个实体 A,其中包含实体 B 的 EntityCollection。 我用定义实体B的行上的[include]装饰更新了实体A的元数据,如下所示:
[Include]
public EntityCollection<daily> daily { get; set; }
在我的域服务类中,我有一个检索实体A的函数,如下所示:
var summary =
(from S in ObjectContext.summery.Include("daily")
where S.daily_number == daily_number
&& S.month_number == month_number
&& S.period_id == period_id
select S).FirstOrDefault();
return summary;
从客户端我总是得到实体B的计数为零。 我在这里缺少什么!!
此致
I have an entityA that contains a EntityCollection of entityB.
I updated the metdata for EntityA with the [include] decoration over the line defining the entityB as follows:
[Include]
public EntityCollection<daily> daily { get; set; }
in my domainservice class I have a function to retrieve entityA as follows:
var summary =
(from S in ObjectContext.summery.Include("daily")
where S.daily_number == daily_number
&& S.month_number == month_number
&& S.period_id == period_id
select S).FirstOrDefault();
return summary;
From the Client I always get count Zero of entityB.
What am I missing here !!
Best regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用 AssociationAttribute。
我对您的课程做出以下假设
编辑:
为了回应 Waleed 的评论,复合外键关联可能看起来像
You'll need to define the association between
summery
anddaily
with the AssociationAttribute.I am making the following assumptions about your classes
Edit:
In response to Waleed's comment, a composite foreign key association could look like