>>Hi everybody,
>>
>>I did a quick research in Google and found that if we want to update multiple rows, we would need to loop through each row and update separately. I just want to make sure it's true and this is what I need.
>
>If I understand correctly, if there are 100 items in your collection, this will fire 100 UPDATE statements back to the database. Am I correct?
Yes but in one transaction if we put SaveChanges at the end.
In any case, I found that it's not working for me as is right now. I have a view which is based on a single table. I didn't add with schemabinding, may be if I add this, it'll help. I also added INSTEAD OF UPDATE trigger for that view. I didn't have a chance yet to test if anything is going on when I issue the SaveChanges method. But I noticed that in the configuration file that was auto-generated by Reverse POCO generator every single column is listed as a key. I think this may be part of a problem and it will probably be resolved if I add schemabinding.
BTW, while I am at this. In our code in the update method (which was originally for a single row) we just use this code:
try
{
EntityState entityState = _siriusContext.GetEntityState(entity);
if (entityState == EntityState.Detached)
{
_dbSetList.Attach(entity);
}
if (_siriusContext != null)
_siriusContext.SetModified(entity);
SaveChanges();
So, we always just set the Modified state manually. In my case when I send the list, I'd rather set only changed rows that state. Is there a method that will check for actual changes? I assume there should be one and EF is supposed to be working OK for a view.
If it's not broken, fix it until it is.
My Blog