How to obtain column metadata from linq to Entities query?

I need to support legacy client and compose ADO datasets from our Linq queries. The problem is how get specific column information (varchar length, decimal precision, etc) that cannot be obtained using reflection.

for example, I have table Customer with field Name varchar(80)

When I fetch data from linq to entities query:

var data = (from c in ctx.Customers select c.Name).ToList()

I cannot obtain maxSize for the column data[i].Name and adodataset raises an error.

I already have simple solution:

  1. Code to extract column metadata from ObjectContext by property reference
  2. Simple code that parses expression from Queryable and links output properties to edm columns.

But I have a lot of issues parsing complex queries that include multiple nested groupbys/unions/joins etc.

Does anybody know any other way (maybe using materialization shaper or similar)?


Thanks to EFProviderWrappers by Joseph Kowalski I have made similar provider and published it on codeplex

Need Your Help

LINQPad throws NullReferenceException on valid code

c# events delegates nullreferenceexception linqpad

I'm reading about C# events and delegates, and I'd like to copy and paste the following code into LINQPad and run it:

Instance “Main” Method Not Running When Called from Another Class

java netbeans

I'm learning Java and experimenting with Javafx in netbeans.