c# - Expression<Func<T1, T2, TResult>> and Sql IN -
i want use expression trees make filters entity framework.
so types
public class type1 { public string name { get; set; } } public class type2 { public ienumerable<string> names { get; set; } }
and specification
public expression<func<entities.type1, bool>> myexpression(type2 filter) { //something name in (name[0], name[1], ... name[n]) }
i need transform in sql in.
how can it, , what's best form?
how can make entity framework understand arbitrary expression in way want?
you can this:
public expression<func<type1, bool>> myexpression(type2 filter) { return x => filter.names.contains(x.name); }
Comments
Post a Comment