Linq to SQL :How to work with already existing Business objects(Handwritten)
I was trying to implement a LINQ 2 SQL implementation to one of my page to 开发者_运维知识库load the data to a datagrid.The below is the code
using (NorthwindDataContext context = new NorthwindDataContext())
{
var customers =from c in context.Customers select c; // Line 1
gridViewCustomers.DataSource = customers;
gridViewCustomers.DataBind();
}
I put a break point in the Line 1 to examine what type is being loaded into customer .But i couldn't see anything there. What type this customer is of ?
I wanted to put the code to fetch data from Tables in my data access layer which is a seperate classlibrary and would like to call it from UI.What should be the return type of my method in Data access layer ? I already have a another class library which holds buisness objects/entities (Ex: Student).I was using this with Normal ADO.NET stuff before using the LINQ 2SQL stuff.How can i make it work altogether .Kindly advice
You need a LinqDataSource
or ObjectDataSource
to bind the Linq query to the GridView.
See here and here for examples.
精彩评论