LINQ to SQL : Executing SQL Query

LINQ to SQL : Executing SQL Query

  • Comments 0

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!!!

Leave a Comment
  • Please add 1 and 6 and type the answer here:
  • Post