I have a query where I am calculating flag and based on the flag value, I am filtering users. Is there a way to store flag value inside query so that I dont need to call flag function twice?
[Name("AutoRepoRule")]
public class AutoRepossessionRule : BaseRule
{
public override void Define()
{
CReport cReport = default;
IEnumerable<Report> reports = default;
IEnumerable<Report> failedUser = default;
When()
.Match(() => cReport,
c => c.Product == "ABC" &&
c.reports.Any(x => GetAutoRepoFlag(x.Liabilities)))
.Let(() => failedUser, () => cReport.reports
.Where(x => GetAutoRepoFlag(x.Liabilities)));
Then()
.Do(ctx => DeclineApplication(failedUser, ref cReport,
"Rejected"))
.Do(ctx => ctx.Insert("AutoRepoRule"));
}
}
where as
protected bool GetAutoRepoFlag(List<Liability> liabilities)
{
.
.
.
}
Is there a way to store flag inside Any so that I dont need to call GetAutoRepoFlag() function twice