Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have more than 40 tables.First table primary key (id) is the foreignkey for reset/some of the tales.
I want to delete all records related to id=2 in sub tables(including base table) in a single query.

can any one help this.......

Thanks,
Ananth
Posted
Updated 18-Feb-10 0:45am
v2

Have a look at this[^] excellent post to start you up.
 
Share this answer
 
Are you using LINQ to SQL ?

If so, you can easily get the Enumerable of recordes that you want to delete and then use RemoveAll method on the Table to remove all the records present in the Enumerable.

var recordstodelete = from x in emp where emp.jobid = 2 select x;


now after you get this call:
dbml.Emp.RemoveAll(recordtodelete);
dbml.SubmitChanges();


this is all u need.
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900