In “LINQ to SQL”, we can use
ExecuteQuery
method of
DataContext
object to Execute SQL queries as follows:
Reference:
LINQ to SQL – Execute SQL Queries.
class Program
{
static void Main(string[] args)
{
NorthWindDataContext context = new NorthWindDataContext();
IEnumerable<Category> catList = context.ExecuteQuery<Category>(
"Select c1.CategoryId, c1.CategoryName from Categories as c1");
foreach (var item in catList)
{
Console.WriteLine(item.CategoryName);
}
}
}