我正在尝试编写动态 lambda 或查询,但它发生错误..
对于拉姆达;我创建了一个函数
public IEnumerable<musteriler> GetCustomers<musteriler>(Expression<Func<musteriler, bool>> where)
{
IEnumerable<musteriler> _musteriler = market.musteriler.Where(where).Select(m => m);
return _musteriler;
}
我就这样打电话
IEnumerable<musteriler> _musteriler = helper.GetCustomers<musteriler>(m => m.MAktif == true);
我在 Where( where ) 中得到两个错误,它们是
The best overloaded method match for System.Data.Objects.ObjectQuery<AkilliMarket.musteriler>.Where(string, params System.Data.Objects.ObjectParameter[])' has some invalid arguments
和
Argument 1: cannot convert from 'System.Linq.Expressions.Expression<System.Func<musteriler,bool>>' to 'string'
在我尝试了一个字符串查询之后
IEnumerable<musteriler> _musteriler= market.musteriler.Where("MAktif = true").Select(m => m) as IEnumerable<musteriler>;
是的,它有效,但我不能使用 _musteriler.. 例如当我写 _musteriler.Count(); 我收到这个错误
'MAktif' could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly. Near simple identifier, line 6, column 1.
MAktif 是我在 db 中的 musteriler 表的列名。我尝试了另一列,但结果相同..
我的错误在哪里?