linq - Retrive value of lambda expression -
i have function :
public static iqueryable<tsource> whereif<tsource>(this iqueryable<tsource> source, expression<func<tsource, bool>> exp1, expression<func<tsource, bool>> exp2, expression<func<tsource, bool>> exp3) { } and use function :
adverts.whereif(x=>x.deactivateddate.hasvalue, x => x.deactivateddate.value > stardatetime, x => x.modifieddate > stardatetime); how can value of exp1 ?
in extenssion need know if deactivateddate.hasvalue true
you can evaluate expression, need instance of tsource evaluate against. since "input" collection of tsource youe solution might like:
foreach(tsource t in source) { bool istrue = exp1.compile()(t); // evaluate exp1 item if(istrue) // else // else } but note return type in iqueryable<tsource> - i'm not sure you've thought through how intend build resulting query...
Comments
Post a Comment