LINQ Support
LINQ is a great way to retrieve data from your datasources. LINQ lets you build intuitive query expressions in any language of your choice with optional support for transforming/projecting/shaping the data into many different forms before it gets displayed in the UI. For more on LINQ, see http://msdn.microsoft.com/en-us/netframework/aa904594.aspx.
The Grid now supports binding to LINQ through the "Pass through grouping" feature introduced in the previous section. Binding the grid with LINQ results provides you many advantages. Without binding to LINQ, by default, the grid will retrieve all the records in the bound data source to the server even if only a few of them are displayed in the current page, or even if all groups are currently collapsed. This could become a serious overhead while dealing with large data sources. To overcome this, instead of binding the grid to the data source directly, bind it to the LINQ query results. When you do so, data from your data source is retrieved on demand, as and when the user requests it (by expanding a collapsed group, for example).
Note that LINQ queries often return anonymous types. Anonymous types are a convenient language feature of C# and VB that enable developers to concisely define inline CLR types within code, without having to explicitly define a formal class declaration of the type.
Since Anonymous types are compiler generated typed objects, the grid cannot serialize it with default formatters ( Binary / XML ). So, LINQ query results cannot be saved in the ViewState, it can only be saved in the session.
|