Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 是否有一种方法可以定义。在何处内部。包括_C#_Linq_Entity Framework - Fatal编程技术网

C# 是否有一种方法可以定义。在何处内部。包括

C# 是否有一种方法可以定义。在何处内部。包括,c#,linq,entity-framework,C#,Linq,Entity Framework,我有以下模型类方法:- public IQueryable<TMSSwitch> AllFindServer_Switches(int id { return tms.TMSSwitches.Where(c => c.TMSSwitchPorts.Any(a6=>a6.TechnologyID == id)) .Include(a10 => a10.TMSSwitchPorts.Where(a=>a.TechnologyID==id).S

我有以下模型类方法:-

public IQueryable<TMSSwitch> AllFindServer_Switches(int id        {



return tms.TMSSwitches.Where(c => c.TMSSwitchPorts.Any(a6=>a6.TechnologyID == id))

.Include(a10 => a10.TMSSwitchPorts.Where(a=>a.TechnologyID==id).Select(a=>a.Technology))
.Include(a11 => a11.TMSServer.Technology)
;}
public IQueryable AllFindServer_开关(int-id{
返回tms.tmswitches.Where(c=>c.tmswitchport.Any(a6=>a6.TechnologyID==id))
.Include(a10=>a10.tmsswitchport.Where(a=>a.TechnologyID==id)。选择(a=>a.Technology))
.Include(a11=>a11.TMSServer.Technology)
;}
但是我无法定义.Include中的.Where,因为我只需要包含导航属性中的某些记录。但是上面的代码将在运行时导致以下错误:-

包含路径表达式必须引用导航属性 在类型上定义。使用虚线路径进行参考导航 属性和集合导航属性的选择运算符

如果有办法将
.Where
放在
.include
中,有人能提供建议吗?
谢谢

您的.Any中已经有了您的状况,那么为什么会返回没有链接到所选TMSSwitch的任何TMSSitchPort?如果您只使用
,会发生什么(a10=>a10.TMSSwitchPorts.Technology
?但是.Any与.Where.all不同。所有的TMSSwitchPort都将有到TMSSwitches的链接。但是TMSSwitchPort导航属性可以有到其他交换机的其他链接。因此,我尝试只选择与交换机相关的TMSSwitchPorts,但同时不包括其他l链接到其他交换机..是的,是的。但是既然您的Any means yuo只选择具有相关TMSSwitchPorts的TMSSwitchPorts,为什么会包括任何不相关的TMSSwitchPorts?没有这些的结果是什么。在哪里?您是否有任何迹象表明您接收到的TMSSwitchPorts未链接到所选TMSSwitch?当前检索到的SwitchPorts将至少有一个指向关联TMSSwitch的链接,但检索到的SWitchPorts导航属性也可以有指向其他TMSSSwitches的其他链接…我正在尝试对其进行验证。目前,我正在使用item.TMSSwitchPorts.Where(a=>a.TechnologyID==ViewBag.ID)中的:-var item2对视图进行筛选.但是我需要在我的模型类中进行过滤是的,我遗漏了一些东西。你是对的,你确实有额外的开关。我必须考虑一下