【发布时间】:2011-04-12 09:51:09
【问题描述】:
以下 EF 语句无法编译,因为它需要 2 个附加参数,一个 int 和一个 bool。我不知道如何提供它们或它们的用途。
Dim L2 = Db.SecurityLogs.Where(Function(x) x.OrderId = OrderId)
编译错误是;
Error 27 Overload resolution failed because no accessible 'Where' can be called with these arguments:
'Public Function Where(predicate As String, ParamArray parameters() As System.Data.Objects.ObjectParameter) As System.Data.Objects.ObjectQuery(Of SecurityLog)': Lambda expression cannot be converted to 'String' because 'String' is not a delegate type.
Extension method 'Public Function Where(predicate As System.Func(Of SecurityLog, Integer, Boolean)) As System.Collections.Generic.IEnumerable(Of SecurityLog)' defined in 'System.Linq.Enumerable': Nested function does not have a signature that is compatible with delegate 'System.Func(Of SecurityLog, Integer, Boolean)'.
Extension method 'Public Function Where(predicate As System.Func(Of SecurityLog, Boolean)) As System.Collections.Generic.IEnumerable(Of SecurityLog)' defined in 'System.Linq.Enumerable': Option Strict On disallows implicit conversions from 'Boolean?' to 'Boolean'.
Extension method 'Public Function Where(predicate As System.Linq.Expressions.Expression(Of System.Func(Of SecurityLog, Integer, Boolean))) As System.Linq.IQueryable(Of SecurityLog)' defined in 'System.Linq.Queryable': Nested function does not have a signature that is compatible with delegate 'System.Func(Of SecurityLog, Integer, Boolean)'.
Extension method 'Public Function Where(predicate As System.Linq.Expressions.Expression(Of System.Func(Of SecurityLog, Boolean))) As System.Linq.IQueryable(Of SecurityLog)' defined in 'System.Linq.Queryable': Option Strict On disallows implicit conversions from 'Boolean?' to 'Boolean'. D:\Projects\OutdoorAndCountry\trunk\Source\Server\DataModel\SecurityLogDb.vb 24 22 DataModel
我以为我理解了如何使用 Where 方法,所以我必须以不同于通常的方式调用它,而 MSDN 似乎只是指不带参数的函数的传递。
我错过了什么?
提前致谢,
瑞恩
【问题讨论】: