表引用来自同一表的2个外键 - 实体框架 [英] Table references 2 Foreign Key from the same table - Entity Framework

查看:65
本文介绍了表引用来自同一表的2个外键 - 实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑我有以下表格TeamDetails的结构



团队详情

------------ -------------------

Id =>表的主键

TeamId =>表格团队的参考ID(导航属性(团队1))

DefaultTeam =>表格Team或Null的引用ID(Navidation Property(Teams))





这里的实体框架我正在使用导航属性并考虑我我在radGrid中显示数据。

我的问题是

当我尝试通过Teams.name和Teams1.name使用两者的导航属性时,我得到了数据仅在Teams.name列(即默认TeamId)和Teams1.name中,仅当数据与Teams.name中的任何其他元素匹配时,才会显示数据。

例如

团队|| DefaultTeam

==========================

Team1 || Team2

|| Team3(实际结果必须是Team4 || Team3)

Team3 || Team1



这里Team4不可见,因为它不在defaultTeam的任何元素中。我不知道这是这样的。如果你们解释它是这样显示并得到确切结果会很好

Consider I have the following structure of Table TeamDetails

Team Details
-------------------------------
Id => primary key of the table
TeamId=> references ID of table Team (Navidation Property (Teams1))
DefaultTeam=> references ID of table Team or Null (Navidation Property (Teams))


here in Entity framework I am using Navigation Properties and consider I am displaying the data in a radGrid.
my problem is
When i try to use the navigation property of both through Teams.name and Teams1.name, I get the data only under the column Teams.name (ie default TeamId) and in Teams1.name only when the data matches with any other elements in Teams.name , the data is displayed.
For example
Team || DefaultTeam
==========================
Team1 || Team2
|| Team3 (actual result has to be Team4 || Team3)
Team3 || Team1

here Team4 is not visible because it is not in any of the elements of defaultTeam. I dont know y this is showing like this. Would be good if u guys explain y it is showing like this and to get the exact result

推荐答案

我得到了解决方案。

我在EntityDatasource中做了Include =Teams,Teams1(由radGrid用作数据源)。现在工作正常。

但我还需要更多解释对于这个。?

我现在的问题是如果我没有引用Teams1属性,那么它首先显示在网格中(对于匹配的元素)。



谢谢
I got the solution for this.
I did "Include="Teams,Teams1" in EntityDatasource (which is used as a datasource by radGrid). Now it is working fine.
But I need more explanation for this. ?
My question now is If I am not referring the Teams1 property, then it got displayed in the grid firstplace(for the matched elements).

Thanks


这篇关于表引用来自同一表的2个外键 - 实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆