LINQ to SQL : Writing DML query to perform quick operation

LINQ to SQL : Writing DML query to perform quick operation

  • Comments 1

In LINQ to SQL you also can send the DML query to perform the quick database modification.

 

Caution!!! It is not recommended as it does not support object model so has no compile time checking.

 

static void Main(string[] args)

{

    string strConnection = @"Data Source=wriju-orcas\sqlexpress;Initial Catalog=TestDB;";

 

    TestDB db = new TestDB(strConnection);

 

    //To check the SQL query

    db.Log = Console.Out;

 

    //INSERT

    db.ExecuteCommand("INSERT INTO Emp(Name) VALUES('Wriju')", "");

 

    //DELETE

    db.ExecuteCommand("DELETE FROM Emp WHERE Id = 19", "");

 

    //UPDATE

    db.ExecuteCommand("UPDATE Emp SET Name = 'A' WHERE Id = 21", "");

 

    //Check the rows inside table

    ObjectDumper.Write(db.Emps);

}

 

 

Namoskar!!!

Leave a Comment
  • Please add 1 and 7 and type the answer here:
  • Post
  • In LINQ to SQL you also can send the DML query to perform the quick database modification. Caution!!

Page 1 of 1 (1 items)