LINQ compiled query DataBind issue

Posted by Brian on Stack Overflow See other posts from Stack Overflow or by Brian
Published on 2010-04-07T21:13:12Z Indexed on 2010/04/07 21:43 UTC
Read the original article Hit count: 481

Hello All,

I have a pretty extensive reporting page that uses LINQ. There is one main function that returns an IQueryable object. I then further filter / aggregate the returned query depending on the report the user needs.

I changed this function to a compiled query, it worked great, and the speed increase was astonishing.

The only problem comes when i want to databind the results.

I am databinding to a standard asp.net GridView and it works fine, no problems.

I am also databinding to an asp.net chart control, this is where my page is throwing an error.

this works well:

GridView gv = new GridView();
gv.DataSource = gridSource;

But this does not:

Series s1 = new Series("Series One");
s1.Points.DataBindXY(gridSource, "Month", gridSource, "Success");

The error i receive is this: System.NotSupportedException Specified method is not supported

When i look into my gridSource var at run time i see this using a typical linq query:

SELECT [t33].[value2] AS [Year], [t33].[value22] AS [Month], [t33].[value3] AS [Calls]......

I see this after i change the query to compiled:

{System.Linq.OrderedEnumerable<<>f__AnonymousType15<string,int,int,int,int,int,int,int>,string>}

This is obviously the reason why the databindxy is no longer working, but i am not sure how to get around it. Any help would be appreciated!

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ