動的ラムダまたはクエリを書き込もうとしていますが、エラーが発生します。
ラムダの場合; 関数を作成しました
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)で2つのエラーが発生します。
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テーブルの列名です。別の列を試しましたが、結果は同じです。
両方の間違いはどこにありますか?