I want to add a dynamic expression in linq, but problems with the problem contain a method that works fine for the Equal method
The problem is that I get FilterFielddynamically how to replace a request
So far i tried
List<int> Ids = new List<int>();
**string filterField ="DEPARTMENT"; ==> Dynamic Field**
var eParam = Expression.Parameter(typeof(EmployeeDetail), "e");
var comparison = Expression.Equal(Expression.Property(eParam, filterField), Expression.Convert(Expression.Constant(Ids), Expression.Property(eParam, filterField).Type));
var lambda = Expression.Lambda<Func<EmployeeDetail, bool>>(comparison, eParam);
var countMonthly1 = ctx.tblMonthlyInput.Join(ctx.tblEmployee, a => a.CompanyId, b => b.CompanyId, (a, b) => b).Where(lambda).Count();
I want to do over query execution for the Contains method using the linq expression
Request example:
var countMonthly = (from a in ctx.tblMonthlyInput
join b in ctx.tblEmployee on a.CompanyId equals b.CompanyId
where categoryId.Contains(a.CategoryId)
select a).Count() == 0;
source
share