I need to have "Where" Linq functionality in my own code.
Let me explain: we have an application that lets users write the so-called "user code", which is code in C# that will be picked up by the app and compiled and run at runtime.
In user code, I need to be able to specify an SQL condition. A special case is the condition on a date column. We may have conditions like [DateColumn] = '1/1/2001' which are easy to implement, but also [DateColumn] = GetDate() + 1. In the latter case I would need to implement an parser to "understand" the expression. I don't want to blindly send to SQL whatever the user enters (avoid SQL injection).
The user would be most pleased to write a Linq-like query like this:
xxx.Where(field => field == new DateTime(2001, 1, 1));
xxx.Where(field => field == DateTime.Now.AddDays(1));
Is it possible to leverage the Linq to SQL framework in any way? I would need the SQL generated in the back to further construct the whole query and send it to SQL Server.
Are there any 3rd party tools that may help me?
I don't require the whole IQueryable interfaces (to compose, join querys etc.). Only the ability to convert a System.Linq.Expressions.Expression to T-SQL (even with limitations).
What is the System.Linq.* namespace that exposes this conversion functionality for SQL? Maybe I can get a few hints with Reflector.
Thank you very much.