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
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Antonis P
NA
1
1.9k
LINQ to SQL Thread safety
Oct 23 2012 2:58 PM
Hi,
I want to ask whether the following code is thread safe:
Consider that Save1 and Save2 will be executed concurrently. Is there any problem with the thread safety of the datacontext?
public class Test1()
{
private void Save1()
{
using(TestLinqToSQL obj = new TestLinqToSQL())
{
obj.SaveRecord(new Client (){Id = 1, Name = "John Doe");
}
}
private void Save2()
{
using(TestLinqToSQL obj = new TestLinqToSQL())
{
obj.SaveRecord(new Client (){Id = 2, Name = "Mike Tyson");
}
}
}
public class TestLinqToSQL : IDisposable
{
public void SaveRecord(Client newClient)
{
using(ClientDatacontext cont = new ClientDatacontext())
{
cont.InsertRecord(newClient);
}
}
}
Thanks in advance
Reply
Answers (
1
)
What is wrong in this query
foreach statement cannot operate on variables of type 'int' because 'int' does not contain a public definition for 'GetEnumerator'