多分あなたは次のようなものが必要です:
//use a method because use a foreach in a lambda expression isn't allowed
public bool myFunction(vw_UsuarioPerfilAtributo Perf){
foreach(int _key in Keys){
if(Perf.Id == _key || /*other condition here*/)
return true;
}
return false;
}
と:
Func<vw_UsuarioPerfilAtributo, bool> expressionPerfil = Perf => myFunction(Perf);
あるいは単に:
Func<vw_UsuarioPerfilAtributo, bool> expressionPerfil = Perf => Keys.Any(_key => Perf.Id == _key || /*other condition here*/);
これはより速いと思います
teste.add(context.Find(Id));
この場合context.Find(id)
(コンテキストはList<>
)は見つかった要素を返しますが、前のコードは次の理由でブール値を返します。Func<vw_UsuarioPerfilAtributo, bool>