TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
LINQ To SQL:Creating a new entity
Vijai Anand Ramalingam
Jun 22, 2011
4.3
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
In this blog we will be seeing how to create a new entity.
EmpDetails Table:
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();
}
}
}
Next Recommended Reading
Entity Framework vs LINQ to SQL