David Rasuli
David Rasuli

Reputation: 832

Find which records were not deleted on submit

I have a list of mails in a List objects, which I'd like to delete from my production DB. Some of the mails are invalid-(my client type the wrong address, etc). I want to recieve a list/array of the items (mails) which haven't been deleted-since they weren't exsit at my DB.

I've tried to check the mails at my list before and after the delete and compare them , but this methods feels inefficient. I was wondering if there is a method which tells me which of the objects I wished to delete on linq weren't deleted on

context.MyEmails.DeleteOnSubmit(MailsToDelete);

Many thanks, David

Upvotes: 0

Views: 44

Answers (1)

Baz1nga
Baz1nga

Reputation: 15579

You can do some kind of batching that runs two or more different queries simultaneously against the dB i.e have one query to retrieve the missing records and another to delete and execute it as part of the same dB call. to read more abt batching using linq to sql read this: http://tonesdotnetblog.wordpress.com/2008/07/23/linq-to-sql-batches-and-multiple-results-without-stored-procedures-by-tony-wright/

Upvotes: 1

Related Questions