views:

478

answers:

2

Hi,

I am not deleting records permanently (just maintaining flag) but I'd like to know how cascading delete / update works in LINQ-to-SQL class.

EDIT

If I have similar situation e.g. maintaining flag for Delete option. How do you achieve Cascading Delete for your database?

A: 

u have 2 way ,which i know , for it

  1. a) u should define constraint in data layer ( if FK constraint exist ur issue delete on cascade or update on cascade) b) write stored procedure or function or trigger by using CTE and use it in your app layer
  2. take control in app layer and write your function But my advice is make it on data layer
ibrahimyilmaz
Vikas
If u think that it takes many time,then you write your Stored Procedure Creator(it ll be really usefull your other projects) or use CodeSmith
ibrahimyilmaz
+1  A: 

The database-level delete isn't a perfect solution, in this case DataContext knows nothing about the fact that objects are already deleted. The better way is to handle the situation on the application level using association flags like [Association( ... DeleteRule = "cascade" ... )].

Devart