How do you select all rows when doing linq to sql?
Select * From TableA
In both query syntax and method syntax please.
Assuming TableA as an entity of table TableA, and TableADBEntities as DB Entity class,
IQueryable result;
using (var context = new TableADBEntities())
{
result = context.TableA.Select(s => s);
}
IQueryable result;
using (var context = new TableADBEntities())
{
var qry = from s in context.TableA
select s;
result = qry.Select(s => s);
}
Native SQL can also be used as:
IList resultList;
using (var context = new TableADBEntities())
{
resultList = context.TableA.SqlQuery("Select * from dbo.TableA").ToList();
}
Note: dbo is a default schema owner in SQL Server. One can construct a SQL SELECT query as per the database in the context.