Friday, October 19, 2007 5:43 PM
Does anyone know of a good way to do a Cascading Delete from a GridView using a LinqDataSource?
I currently have a relationship that looks like Customer has an Address. When I delete customer I would like to delete the orphaned address at the same time. The delete from the LinqDataSource doesn't seem to take this relationship into account. Any ideas?
Tuesday, October 23, 2007 4:37 AM
As far as I know, you can do the cascading delete in database side, for example sql server has such a setting in foreign key settings.
Tuesday, October 23, 2007 6:03 AM
You can uset the DeleteCustomer() Partial method of the DataContext class to perform the cascaded Delete
For exampleCode Block
public partial class MyDataContext
partial void DeleteCustomer(Customer instance)
var DeletedAddresses = from a in Address
where a.CustomerID = instance.CustomerID
//or use this line if you have an association