Linq to SQL Design Question

Often I need to combine data from multiple tables and display the result in a GridView control.

I can write the Linq inline query in the Page_load event, return an anonymous type that combines all the fields I need and bind the result to the GridView control.

  • Problem: I use "helper methods" as described by Scott Guthrie on his blog . Such a helper method cannot return an anonymous type. A query must be built in for this approach.

I can write a database view that returns the data I need and write a helper method with a request for this (new and well-known) type that it returns.

  • Problem: I will need a lot of views in my database schema, and I will talk about many redundant aspects of my data. I also lose some of the benefits of using Linq - removing all business logic from the database.

I would like to use an approach that allows me to store Linq queries in helper methods, but allows me to access all the attributes that I need in the grid, in their respective data binding expressions. It can be done?

+5
source share
3 answers

, . , , GridView - <asp:BoundField> ( DataField , Linq).

, TemplateField Eval Linq, Linq . , , (, ) GridView. Account, , . .

+1

, , ​​:

3 -

" ".

0

All Articles