Blog

LINQ To SQL:Creating a new entity

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

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs