Dear all,
despite the many threads about the PredicateExpression as well as the documentation, i didn't manage to get rid yet of the below issue.
I'm currently using LLBLGen v5.10, Selfservicing.
There is a table containing approximately 5k rows which needs to be filtered according to some criteria (e.g.: UserId, AttemptId, SubjectId).
As not all filter criteria might be filled at the same time (e.g.: there could be only the UserId or UserId+AttemptId or AttemptId), and as I prefer not to retrieve all the 5k items from the database first and then apply the filtering, I thought that the PredicateExpression could be the right stuff.
Therefore, I wrote the below code:
var filter = new SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression();
if (userId != Guid.Empty)
{
filter.Add(ViewQuizAttemptFields.UserId == userId);
}
if (quizSubjectId != Guid.Empty)
{
filter.Add(ViewQuizAttemptFields.QuizSubjectId == quizSubjectId);
}
if (quizAttemptId != Guid.Empty)
{
filter.Add(ViewQuizAttemptFields.QuizAttemptId == quizAttemptId);
}
LinqMetaData md = new LinqMetaData();
List<ViewQuizAttemptEntity> viewQuizAttempt = md.ViewQuizAttempt.Where(filter);
The issue is when I try to pass the "filter" to the "Where" because the compiler says:
'SD.LLBLGen.Pro.LinqSupportClasses.DataSource<xxx.DAL.EntityClasses.ViewQuizAttemptEntity>' cannot be used as type parameter 'TQuery' in the generic type or method 'QuerySpecExtensionMethods.Where<TQuery>(TQuery, IPredicate)'. There is no implicit reference conversion from 'SD.LLBLGen.Pro.LinqSupportClasses.DataSource<xxx.DAL.EntityClasses.ViewQuizAttemptEntity>' to 'SD.LLBLGen.Pro.QuerySpec.QuerySpec'.
Is there anyone who can help me in fixing this error? Perhaps it's me building things in the wrong way...
Any help would be appreciated.
Thanks.