|
LINQ Support
The LINQ method is great to retrieve data from datasources. LINQ lets you build intuitive query expressions in a language of your choice with optional support for transforming, projecting or shaping the data into many different forms before it gets displayed on the User Interface(UI). For more information 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 using LINQ has many advantages. When binding a datasource to the grid without using LINQ, the grid will retrieve all records from the bound datasource to the server, though only few are displayed on the page. This could become a serious overhead while dealing with large datasources. This may be resolved by binding the grid to the LINQ query results instead of the datasource directly. Thus, data from the datasource is retrieved on demand, upon user request(for example,by expanding a collapsed group).
Note that LINQ queries often return anonymous types. Anonymous types are a convenient language feature of Microsoft Visual C# and Microsoft Visual Basic that enable developers to concisely define inline CLR(Common Language Runtime) 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 and can only be saved in the session.
|
|
|
|