i want to get result where a column values are NULL using LINQ Expressions
search.AddCriteria(x => x.LogStatus ==
Inventory.AffStatusToChar((EAffidavitLogStatus)byte.Parse(cmbLog.SelectedValue)));
public void AddCriteria (Expression<Func<T, bool>> criteria) {
if (_where == null) { _where = w => true; }
_where = And(criteria);
}
private Expression<Func<T, bool>> And (Expression<Func<T, bool>> expr) {
return Expression.Lambda<Func<T, bool>>(Expression.And(
_where.Body,
Expression.Invoke(expr, _where.Parameters.Cast<Expression>())
), _where.Parameters);
}
//This below part is use to execute the Linq
//IQueryable<T> result = db.GetTable<T>();
//result = result.Where(_where);
result’s where part is looking like WHERE ([t0].[LogStatus]) = @p5)
see i want IS NULL
I want query like this
SQL query : `select * from xyz where abc is NULL`
but the LINQ expression above is converting to
select * from xyz where abc=NULL which gives a different result.
any one gone through this kind a problem? how can IS NULL in LINQ expression achieve this?
Never mind i figured it myself here is the solution what i did
this returns query like
tada!! this is what i expected..