Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.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
Entity framework Entity Framework.Include不支持具有超过8个点分隔名称的路径_Entity Framework_Include Path - Fatal编程技术网

Entity framework Entity Framework.Include不支持具有超过8个点分隔名称的路径

Entity framework Entity Framework.Include不支持具有超过8个点分隔名称的路径,entity-framework,include-path,Entity Framework,Include Path,我在Microsoft Connect上为此打开了一个bug,但很长一段时间没有响应(请参见下面的编辑以了解他们的响应)。下面是: 当尝试使用linq查询中的“Include”函数请求实体框架及其关系时,不可能通过超过8个步骤(路径中有8个点字符)的路径请求关系。这会阻止我完成一些动态生成的查询,这些查询需要访问超过该级别的重定向 我没有成功完成查询,而是出现以下异常: "Foo.Bar.Baz...(some more path string here)", the current limit

我在Microsoft Connect上为此打开了一个bug,但很长一段时间没有响应(请参见下面的编辑以了解他们的响应)。下面是:

当尝试使用linq查询中的“Include”函数请求实体框架及其关系时,不可能通过超过8个步骤(路径中有8个点字符)的路径请求关系。这会阻止我完成一些动态生成的查询,这些查询需要访问超过该级别的重定向

我没有成功完成查询,而是出现以下异常:

"Foo.Bar.Baz...(some more path string here)", the current limit of "8" is insufficient.

at System.Data.Common.MultipartIdentifier.IncrementStringCount(String name, String[] ary, Int32& position, String property)
at System.Data.Common.MultipartIdentifier.ParseMultipartIdentifier(String name, String leftQuote, String rightQuote, Char separator, Int32 limit, Boolean removequotes, String property, Boolean ThrowOnEmptyMultipartName)
at System.Data.Objects.Span.ParsePath(String path)
at System.Data.Objects.Span.Include(String path)
at System.Data.Objects.Span.IncludeIn(Span spanToIncludeIn, String pathToInclude) 
有没有人知道为什么会这样,或者有没有办法解决这个问题?看看ParsePath的代码(带有反射器),似乎他们在那里硬编码了魔法数字8

更新:微软的回应:

谢谢你提出这个问题。我们计划在下一版本中取消包含路径中元素数量的限制

更新2:尽管上面引用了微软的回应,但EF 4.1并未修复该漏洞


更新3:根据Microsoft的说法,应该在.NET 4.5中修复,但我没有测试开发人员预览是否有效。

我没有看到这一点,但这里有两种可能的解决方法:

  • 循环浏览数据,并对每行使用加载。注意,这将为每一行创建对数据库的调用,因此速度非常慢

  • 展平视图中的数据,然后从视图中选择。这会产生大量冗余数据,因此会占用更多内存和网络


    • 可能在最新的.net 4.5中修复

      谢谢,但不幸的是,这两种解决方案都不够好……我希望Microsoft能够真正修复(或解释)该漏洞,或者至少是一种不需要修改数据库或滥用性能的解决方案。这是意料之中的,因为4.1不是下一个版本。它只是4.0的包装,不会改变现有程序集中的任何内容。感谢您更新SO问题