Blog

LINQ To SQL:Creating a new entity

Posted by Vijai Anand Blogs | LINQ Jun 22, 2011
In this blog we will be seeing how to create a new entity.
EmpDetails Table:

LinqTable.png


Code:


To create a new entity to the EmpDetails table.


using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
LINQ
{
class Program
{
static void Main(string[] args)
{
DataClassesDataContext dc = new DataClassesDataContext();
EmpDetail newEmp = new EmpDetail();
newEmp.Name =
"Ranjith";
newEmp.Location =
"Mumbai";
newEmp.ID = 8;
newEmp.Dept =
"LN";
newEmp.Allowance = 56300;
dc.EmpDetails.InsertOnSubmit(newEmp);
dc.SubmitChanges();
}
}
}
COMMENT USING
PREMIUM SPONSORS
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.
SPONSORED BY
  • MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.