Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Logic problem
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Logic problem
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01606497
Message ID:
01606497
Views:
65
Hi everybody,

The original code didn't work and I adjusted it this way, but now it also doesn't work correctly.

Here is the code
  foreach (var itemId in itemIds)
                {
                    if (!modifierGroup.Items.Select(x => x.ItemId == itemId).Any())
                    {
                        const string deleteQuery = "DELETE FROM [dbo].[ModGrpLnk] WHERE ModGrpId = @ModGrpId AND ItemID = @ItemID";
                        rowsAffected = connection.Execute(deleteQuery, new { ModGrpId = modifierGroup.GroupId, ItemID = itemId }, transaction);
                    }
                }
itemIds is a list of 5 items. modifierGroup.Items have 4 items (so one Id is missing and I want to delete that row from the database).

modifierGroup.Items has list of items entries (Items have ItemId among other properties).

So, I want to delete the record if the itemId from itemIds array is not found in the modifierGroup.Items list. My current code doesn't delete anything at all.

What may be the problem here?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform