Dynamic construct where statement with Brackets!! RRS feed

  • Question

  • Dear all,

    I am trying to construct a dynamic query (only the where statement) using Linq to SQL.

    It is something like this:

    var a = from q in db.UserTbl
               where ( ..... something ..... ) AND/OR ( ..... something .....)
               select q;

    Sample query would be like:

    var a = from q in db.UserTbl
               where (UserID=="Lee" || UserID="Chui") AND (Privilege==1 || Privilege==5)
               select q;

    The above is just a simplified sample of the actual query.

    Question now is, how can I construct the Where clause step by step and add in the bracket?

    Thanks in advance.
    Tuesday, January 19, 2010 12:09 PM