-1

I have a textbox where the user will enter some SQL:

for example: SELECT * FROM Customers;

I know the LINQ will look something like this:

 var query = 
 from c in Customers.AsEnumerable()
 select c;

The problem I am having is that the user is going to enter a string, so I need to convert this string into a LINQ command:

for eg.

How will I convert "FROM" to from --> a text to a command.

In other words I will want something like:

 var query = 
 toCommand("from") c in Customers.AsEnumerable()
 toCommand("select") c;

Forgot to mention that Customers is stored in a DataTable.

Thanks in Advance.

Dreamer78692
  • 215
  • 5
  • 20

1 Answers1

0

Your question is a bit unclear, but you probably need something along the lines of

var query = 
   from c in Customers
   where c.Name == usersuppliedstring
   select c;
Hans Kesting
  • 38,117
  • 9
  • 79
  • 111
  • Say the user enters "SELECT" in the textbox, I need to take this and convert it to the reserve word select, in other words i am letting the user build up the linq query, and the program to execute the query. – Dreamer78692 Oct 10 '12 at 11:33