Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Logic problem
Message
From
27/08/2014 13:02:13
 
General information
Forum:
ASP.NET
Category:
Other
Title:
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:
01606558
Views:
36
>>>I need to process all missing Ids. I think this code will only get one of them.
>>
>>Oops:
foreach (var i in itemIds.Where(x => modifierGroup.Items.All(y => y.ItemId != x)))
>>            {
>>                //Use i here
>>            }
>
>So, to be absolutely sure, these two are the same, but the first form is better, right?
>
>
>List<int> itemIds = connection.Query<int>(currentItemsQuery, new { ModGrpId = modifierGroup.GroupId }, transaction).ToList();
>                // Delete list
>                foreach (var id in itemIds.Where(x => modifierGroup.Items.All(y => y.ItemId != x)))
>                {
>                    rowsAffected = connection.Execute(this.deleteQuery, new { ModGrpId = modifierGroup.GroupId, ItemID = id }, transaction);
>                }
>
>                // Delete list
>                foreach (var itemId in itemIds)
>                {
>                    if  (!modifierGroup.Items.Any(x => x.ItemId == itemId))
>                    {                        
>                        rowsAffected = connection.Execute(this.deleteQuery, new { ModGrpId = modifierGroup.GroupId, ItemID = itemId }, transaction);
>                    }
>                }
I think so - but untested.....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform