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
开发者_JAVA百科select S).FirstOrDefault();
return summary;
From the Client I always get count Zero of entityB. What am I missing here !!
Best regards
You'll need to define the association between summery
and daily
with the AssociationAttribute.
[Include]
[Association("SomeUniqueName", "summery_id", "parent_summery_id", IsForeignKey = false)]
public EntityCollection<daily> daily { get; set; }
I am making the following assumptions about your classes
public class summery
{
...
public int? summery_id { get; set; }
...
}
public class daily
{
...
// Foreign key to the parent summery
public int parent_summery_id { get; set; }
...
}
Edit:
In response to Waleed's comment, a composite foreign key association could look like
[Association("SomeUniqueName",
"summery_field1, summary_field2, summary_field3",
"parent_summary_filed1, parent_summary_filed2, parent_summary_filed3",
IsForeignKey = false)]
精彩评论