1

I am looking to build this query and am able to do it for 'AND' phrases, but not for 'OR' phrases based off of the format in the link below. The dynamic OR query will be combined with the 'AND' queries.

http://www.codeproject.com/Articles/168981/Guide-to-Creating-Dynamic-LINQ-Queries

Sun Sun Ku
  • 337
  • 1
  • 6
  • 17

3 Answers3

1

Out of the box, creating a nested dynamic OR query isn't easily obtainable. You're probably looking for something like Predicate Builder or Dynamic Linq which will allow you to have the control over how things are converted to SQL.

Steven V
  • 16,357
  • 3
  • 63
  • 76
1

I ended up using the method in the original link posted with sql queries integrated.

http://www.codeproject.com/Articles/168981/Guide-to-Creating-Dynamic-LINQ-Queries

Sun Sun Ku
  • 337
  • 1
  • 6
  • 17
0

What exactly are you trying to query? Do you have any code snippets. From the example you could try modifying this snippet

oDataQuery = oDataQuery.Where(a => a.CustomerID == CustomerID);

to be

oDataQuery = oDataQuery.Where(a => (a.CustomerID == CustomerID) || (a.Something == Something));

Reference this stack overflow question

Community
  • 1
  • 1
Gina
  • 33
  • 1
  • 6
  • 1
    That's easy to do when the operations are all known at compile time. Not so much when they're dynamic, as this question states. – Servy Feb 03 '14 at 22:02