LINQ To SQL:Creating a new entity

By Vijai Anand 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();
}
}
}
Vijai Anand

Vijai Anand has been working in IT industry for over 5 years. He holds Bachelor's degree in Electronics and Communication Engineering. Vijai write articles and blogs related to SharePoint 2013, SharePoint 2010, Silv... Read more

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