views:

48

answers:

1

I'm developing a project where users need to build reporting queries using complex Linq statements to generate data sets.

The best way I could think of to compile these user-generated queries and then execute them is to use the CSharpCodeProvider object to build an assembly and then store the result in a database blob.

Is there anything wrong with this process? Also, how can I restrict the permissions of the user assembly to only allow execution against a limited set of objects that I provide?

Thanks!

+1  A: 

You shouldn't have to save the queries as a generated assembly. A simpler way would be to save the SQL executed against the database for future use. Use the GetCommand method of the DataContext to get the SQL and persist it as a "saved" query.

Dave Swersky
Not exactly what I'm looking for, but this is a really good idea. In this case it would be eSQL since I'm running against the EF but I'm going to revisit this later and I might decide to go with it.
David Pfeffer
Actually with EF it's still SQL that gets executed agains the SQL db. eSQL is used to query Entities.
Dave Swersky