LINQ to SQL : Writing DML query to perform quick operation

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