Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Logic problem
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Logic problem
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01606497
Message ID:
01606497
Vues:
63
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform