I'm new to .NET framework. I am working on a 3 tier ASP.NET application that uses Linq to SQL for data access. I don't know how to return a Linq to SQL result to the UI layer. ON the BLL, I have a code like this:
dataContex db = new dataContex;
var data = db.DB_TBL;
I obviously cannot return var
type. How do I return the query result to the UI layer?
You can return db.DBL_TBL which will return IQueriable. For example,
public IQueriable<DB_TBL> GetTable()
{
dataContex db = new dataContex;
return db.DB_TBL
}
You can also return IEnumerable or List as well. See example below which returns List.
public List<DB_TBL> GetTable()
{
dataContex db = new dataContex;
return db.DB_TBL.ToList();
}
Then in your UI, use the return types.