I faced a little bit problem with Expression<>
.
Is it possible to combine more than 2 expression in to one? Example:
Expression<Func<Event, bool>> searchForLogCorrelationKeyExpression =
x => string.Equals(x.LOG_CORR_KEY, model.CorrelationKey, StringComparison.CurrentCultureIgnoreCase);
Expression<Func<Event, bool>> searchForLsidExpressionExpression =
x => string.Equals(x.LOG_LSID, model.LsId, StringComparison.CurrentCultureIgnoreCase);
Expression<Func<Event, bool>> searchForLogLocationExpression =
x => string.Equals(x.LOG_LOCATION, model.LogLocation, StringComparison.CurrentCultureIgnoreCase);
Expression<Func<Event, bool>> searchForLogTypeExpression =
x => string.Equals(x.LOG_TP, model.LogType.ToString(), StringComparison.CurrentCultureIgnoreCase);
if (model.EndDateTime != null && model.StartDateTime != null)
{
Expression<Func<Event, bool>> searchForLogInDateRangeExpression =
x => model.StartDateTime <= x.LOG_TS && model.EndDateTime <= x.LOG_TS;
}
Expression<Func<Event, bool>> searchForLogByUserIdExpression =
x => string.Equals(x.LOG_USERID, model.UserId.ToString(), StringComparison.CurrentCultureIgnoreCase);
Expression<Func<Event, bool>> searchForLogByLogTextExpression =
x => string.Equals(x.LOG_TXT, model.SearchString.ToString(), StringComparison.CurrentCultureIgnoreCase);
I have 7 expressions that I want to combine in to one and then put it to the method that accepts Expression<Func<Event, bool>>
as a parameter.
Is it possible? I found many example with combining two expressions but they didn't work.