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

my current requirment is , based on scnerio i have to keep deleting particular ids data from multiple tables.

now my question is will it affect performance by doing in linq.

What i am doing is , first checking in linq for particular records in table. If exisist i am deleting those records then moving next to next table.

am i handling this scnerio correctly ?

What I have tried:

C#
//CallOrder Deletion
                var callOrderData = _db.CallOrders.Where(c => c.CallID == callId).ToList();
                if (callOrderData != null && callOrderData.Count > 0)
                {
                    _db.CallOrders.DeleteAllOnSubmit(callOrderData);
                    _db.SubmitChanges();
                }

                //Call Attachment
                var callAttachmentData = _db.CallAttachments.Where(c => c.CallID == callId).ToList();
                if (callAttachmentData != null && callAttachmentData.Count > 0)
                {
                    _db.CallAttachments.DeleteAllOnSubmit(callAttachmentData);
                    _db.SubmitChanges();
                }


and so on ..

there are about 7 tables in a line where i have to check.
Posted
Updated 10-Jul-16 10:02am
v2

1 solution

 
Share this answer
 
v2
Comments
Torakami 8-Jul-16 6:59am    
The solution given shows on delete cascade option , i cant do that in my tables. There are some rules.
deepankarbhatnagar 8-Jul-16 7:13am    
So please review third link.
deepankarbhatnagar 8-Jul-16 7:13am    
Hope this will do..

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