我的数据库中有三个表:
现在我只是想使用这些表和实体框架来检索记录。
select cm.Name, proj.Address from TableA cm
inner join TableC pc on cm.AID = pc.AID
inner join TableB proj on pc.BID= proj.BID
当我查询我的上下文时,我无法看到TableC。我不知道为什么会这样。我尝试将自己加入Linq,但它没有用。
[XmlIgnoreAttribute()]
[SoapIgnoreAttribute()]
[DataMemberAttribute()]
[EdmRelationshipNavigationPropertyAttribute("context", "TableC", "TableA")]
public EntityCollection<TableA> TableAs
{
get
{
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<TableA>("context.TableC", "TableA");
}
set
{
if ((value != null))
{
((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<TableA>("context.TableC", "TableA", value);
}
}
}
[XmlIgnoreAttribute()]
[SoapIgnoreAttribute()]
[DataMemberAttribute()]
[EdmRelationshipNavigationPropertyAttribute("context", "TableC", "TableB")]
public EntityCollection<TableB> TableBs
{
get
{
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<TableB>("context.TableC", "TableB");
}
set
{
if ((value != null))
{
((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<TableB>("context.TableC", "TableB", value);
}
}
}
答案 0 :(得分:0)
您不需要查看联结表。
var results=db.TableA
.Include(a=>a.Addresses)
.Select(a=>new {a.Name,a.Addresses});