LINQ to SQL : Executing SQL Query

Yes, you can run normal SQL queries in LINQ to SQL. Sample looks like (but not recommended as you do not have statement completion and validation)

 

static void Main(string[] args)

{

    NorthwindDBDataContext db = new NorthwindDBDataContext();

    var query = db.ExecuteQuery<Customer>("SELECT * FROM Customers", "");

    ObjectDumper.Write(query);

}

 

One of the benefits of this approach is that you may get your comfort zone. Major drawback is you always need a representable CRL type to store the output.

 

Namoskar!!!