Dynamic linq against a non-dbml object

dynamic-linq expression-trees linq-to-sql

Question

I've been requested to look at how beneficial Linq to SQL would be for a reporting application we're developing. Our reporting table is a large-scale SQL server table with tens of thousands of various sorts of data (String1-500, Int1-500 etc). It contains the outcomes of dynamic reports that the user has created.

A report field is mapped to a column of the type ordinal pair in a second table that we have (i.e. column String1).

I am aware that expression trees may be built against a linq to sql dbml class that can deliver report results. I want to take this a step further and only return the columns that map to fields, with the result being a dynamic type.

Additionally, to prevent having to keep the sizable reporting table class in the dbml.

Is it feasible to execute a dynamic linq query—that is, one that is not a linq to sql entity—against a table that is not in the dbml?

I am aware that this is a distorted version of L2S, and I don't like it. I'm thinking of returning an untyped result set and utilizing plain old ADO.

Thank you,

Ian

1
0
1/31/2011 2:45:33 PM

Popular Answer

Yes, LINQ to SQL may be used to query an object that is not present in the DBML.

The easiest method I can think of is calling DataContext.ExecuteQuery, which will run a SQL query and return a result set. There may be more methods to do this.

If you are certain of the result's type, you may cast it into an object; if not, you can return it as a list of object types.

0
1/31/2011 5:17:55 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow