C# Entity framework implement predicate with multiple arguments

Viewed 45

I have method and that method querying data. In query I am using join to other table. I need call this method from everywhere with different input condition. In that condition can be use properties from all tables. I still need different result by input condition.

My method:

public async Task<IList<ReturnObject>> Get(Expression<Func<Class1, Class2, Class3, bool>> predicate)
{
   var query = from pcp in db.Class1
               from pc in db.Class2
               from bu in db.Class3
               select new { pcp, pc, bu };
    
   var objects = await query.Where(predicate).ToList();
    
   // create result list from returned objects            
    
   return result;
}

But I got this error:

Error CS1503 Argument 2: cannot convert from 'System.Linq.Expressions.Expression<System.Func<Class1, Class2, Class3, bool>>' to 'System.Linq.Expressions.Expression<System.Func<<anonymous type: Class1 pcp, Class2 pc, Class3 bu>, bool>>'

How should I implement predicate or how should I select data?

0 Answers
Related