Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Where" Linq capability in my own application
    text
    copied!<p>I need to have "Where" Linq functionality in my own code. </p> <p>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. </p> <p>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 <strong>[DateColumn] = '1/1/2001'</strong> which are easy to implement, but also <strong>[DateColumn] = GetDate() + 1</strong>. 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 <em>SQL injection</em>).</p> <p>The user would be most pleased to write a Linq-like query like this:</p> <pre><code>xxx.Where(field =&gt; field == new DateTime(2001, 1, 1)); xxx.Where(field =&gt; field == DateTime.Now.AddDays(1)); </code></pre> <p>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.</p> <p>Are there any 3rd party tools that may help me?</p> <p>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).</p> <p>What is the System.Linq.* namespace that exposes this conversion functionality for SQL? Maybe I can get a few hints with Reflector.</p> <p>Thank you very much.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload