我正在使用 Code First EntityFramework (version="6.1.0"
) 和 EntityFramework.Extended(version="6.1.0.96,目前最新版本 here .
DbContext
公开了访问方式如下的 DbSets
:
var set = ctx.Set<MyEntity>();
今天我决定尝试 EntityFramework.Extended 库的 Future Queries,很快就结束了,不知道如何继续。
示例代码如下:
using (var ctx = new MyDbContext())
{
var u = ctx.Set<User>().Future();
var c = ctx.Set<Country>().Future();
var users = u.ToList();
}
关于 Future()
文档,我应该只得到一个对数据库的查询,这是 Future()
方法提供的。查询应在 u.ToList();
处启动,但发生的是我收到如下错误:
JIT Compiler encountered an internal limitation.
堆栈跟踪潜水告诉我这个:
at EntityFramework.Future.FutureQueryBase 1.GetResult()
at EntityFramework.Future.FutureQuery 1.GetEnumerator()
at System.Collections.Generic.List 1..ctor(IEnumerable 1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable 1 source)
at App.Program.Main(String[] args) in c:\Users\...\App\Program.cs:line 25
我真的不知道我错过了什么。我已检查我的 ConnectionString
是否已将 MultipleResultSets
设置为 TRUE
。
我已经使用 EF.Exteneded
的早期构建版本对此进行了测试,但出现了同样的错误。
任何想法都会有很大帮助。
最佳答案
可能是错的,但我认为
ctx.Set<User>()
返回一个 DBSet 而 .Future() 应该在查询结束时使用。也许如果您将 .AsQueryable 附加到 ctx.Set() 的末尾?
ctx.Set<User>().AsQueryable().Future()
另外,如果您以这种方式构建 EF 数据库,我认为您可以只使用 ctx.users。
关于c# - EntityFramework.Extended Future 错误(JIT 编译器内部限制),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23270945/