We are using:
LLBL Gen Pro version 4.2
SD.LLBLGen.Pro.ORMSupportClasses.dll version 4.2.15.1216
SqlServer versions 2008 - 2019
We are using SQL Server views remapped in LLBL to PocoWithLinqQuery objects.
For backward compatibility with previous code, we need to adapt methods that dynamically add certain conditions to the query.
In the past, without Linq, using IPredicateExpressions there was no problem composing the filter dynamically.
Introducing Linq, on the other hand, it's not clear to me how to achieve this result.
Thank you in advance
public void AddFilterConsuntiviOdpDati(ref IQueryable<OdpConsuntiviOdpDatiPOCORow> query,
List<Tuple<int,int>> listMasterDetailFilter)
{
try
{
IPredicateExpression principalPredicate = new PredicateExpression();
foreach (Tuple<int, int> masterDetailFilter in listMasterDetailFilter)
{
IPredicateExpression secondaryPredicate = new PredicateExpression();
if (masterDetailFilter.Item2 == -1)
{
secondaryPredicate.Add(orm.HelperClasses.OdpConsuntiviOdpDatiPOCOFields.IdStabilimento == masterDetailFilter.Item1);
}
else
{
secondaryPredicate.Add(orm.HelperClasses.OdpConsuntiviOdpDatiPOCOFields.IdStabilimento == masterDetailFilter.Item1);
secondaryPredicate.Add(orm.HelperClasses.OdpConsuntiviOdpDatiPOCOFields.IdReparto == masterDetailFilter.Item2);
}
principalPredicate.AddWithOr(secondaryPredicate);
}
}
catch (Exception ex)
{
throw;
}
}