I'm using the latest version of LinqConnect professiona using the MySql provider l and I have the need to create dynamic nested predicates based on provided criteria. I'm trying to do something like the following using PredicateBuilder (http://www.albahari.com/nutshell/predicatebuilder.aspx):
(This is just a very basic example)
Code: Select all
using (var context = new MyDataContext())
{
var inner = PredicateBuilder.False();
inner.Or(x => x.ID == 12345);
inner.Or(x => x.ID == 54321);
var outer = PredicateBuilder.True();
outer.And(x => x.AccountID == 111111);
outer.And(inner);
var myClasses = context.MyClasses.Where(outer).ToArray();
}
Code: Select all
SELECT id, account_id FROM my_class WHERE :p0
Has anyone had any luck with dynamic predicates like this? Is there a better way to do this with LinqConnect?
Thanks,
Cyle