内部的.NET Framework数据提供程序错误1025 [英] Internal .NET Framework Data Provider error 1025
问题描述
IQueryable<Organization> query = context.Organizations;
Func<Reservation, bool> predicate = r => !r.IsDeleted;
query.Select(o => new {
Reservations = o.Reservations.Where(predicate)
}).ToList();
这个查询会引发内部的.NET Framework数据提供程序错误1025的例外,但低于查询不。
this query throws Internal ".NET Framework Data Provider error 1025" exception but below query does not.
query.Select(o => new {
Reservations = o.Reservations.Where( r => !r.IsDeleted)
}).ToList();
我需要使用第一个,因为我需要检查一些if语句构建正确的predicate。我知道,我不能在这个circumtence这就是为什么我通过委托作为参数来使用if语句。
I need to use first one because i need to check few if statement for construct right predicate. I know that i can not use if statements in this circumtence that is why i pass delegate as parameter.
我怎样才能使它发挥作用的第一个查询?
How can i make it work first query ?
推荐答案
虽然上述回答是真实的,请注意,当尝试一个select语句一个人打电话后使用它 AsQueryable已()
明确,否则编译器会认为我们尝试使用IEnumerable的方法,它期待 Func键
,而不是防爆pression&LT; Func键与GT;
While the above answers are true, note that when trying to use it after a select statement one has to call AsQueryable()
explicitly, otherwise the compiler will assume that we are trying to use IEnumerable methods, which expect a Func
and not Expression<Func>
.
这可能是楼主的问题,否则编译器会抱怨的大部分时间,它正在寻找防爆pression&LT; Func键&GT;
和没有 Func键
。
This was probably the issue of the original poster, as otherwise the compiler will complain most of the time that it is looking for Expression<Func>
and not Func
.
演示: 下面将失败:
MyContext.MySet.Where(m => m.SubCollection.Select(s => s.SubItem).Any(expr)).Load()
在下面的工作:
While the following will work:
MyContext.MySet.Where(m =>
m.SubCollection.Select(s => s.SubItem).AsQueryable().Any(expr))
.Load()
这篇关于内部的.NET Framework数据提供程序错误1025的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!