-
-
Save SeanKilleen/0a8ffa639c4916af0585 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ClaimsReportIsMDLFilter : ISearchFilter<vSEARCH_ClaimsReport> | |
{ | |
public Expression<Func<vSEARCH_ClaimsReport, bool>> GetExpression(string valuesToProcess) | |
{ | |
Expression<Func<vSEARCH_ClaimsReport, bool>> mdlIsTrue = item => item.IsMDL == true; | |
Expression<Func<vSEARCH_ClaimsReport, bool>> mdlIsFalse = item => item.IsMDL == false; | |
Expression<Func<vSEARCH_ClaimsReport, bool>> mdlIsNull = item => item.IsMDL == null; | |
var predicate = PredicateBuilder.False<vSEARCH_ClaimsReport>(); | |
if (string.IsNullOrWhiteSpace(valuesToProcess)) | |
{ | |
predicate = predicate | |
.Or(mdlIsTrue) | |
.Or(mdlIsFalse) | |
.Or(mdlIsNull); | |
} | |
else | |
{ | |
if (!valuesToProcess.Contains("0") && !valuesToProcess.Contains("1")) | |
{ | |
throw new ArgumentException("Invalid IsMDL filter attribute specified"); | |
} | |
if (valuesToProcess.Contains("0") && valuesToProcess.Contains("1")) | |
{ | |
predicate = predicate.Or(mdlIsTrue).Or(mdlIsFalse); | |
} | |
if (valuesToProcess.Contains("0")) | |
{ | |
predicate = predicate.Or(mdlIsFalse); | |
} | |
if (valuesToProcess.Contains("1")) | |
{ | |
predicate = predicate.Or(mdlIsTrue); | |
} | |
} | |
return predicate; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment