C# 2010 delete from database
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?