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
scampercat
NA
189
0
C# 2010 delete from database
Jun 19 2012 11:03 PM
I have the following code in a C# 2010 application that uses linq to sql when connecting to a sql server 2008 r2 database.
var attplan = from p in attDataContext.At_Pln
where p.At_id.Equals((int)Session["AttD"])
select p;
attDataContext.At_Pln.DeleteOnSubmit(attplan.FirstOrDefault());
var att = from c in attDataContext.At
where c.At_id.Equals((int)Session["AttD"])
select c;
attDataContext.At.DeleteOnSubmit(att.First());
attDataContext.SubmitChanges();
My problem is the following line of code:
attDataContext.At_Pln.DeleteOnSubmit(attplan.FirstOrDefault());
The At_Plan table can contain 1 to 500 rows that are related to the At table.
I want to use some other statement besides FirstOrDefault() since this only deletes one row in the
attplan table. However, the application will not let me try another commands without obtaining a compile
error.
Thus can tell me what other linq statement that I can use that will let me delete all the records in the
attplan table?
Reply
Answers (
2
)
problem calling my code
In asp.net for textbox I want to type only numbers not character.how to validate.