0
Good morning! I wanted to ask for your help just to see if there’s a better way to do it.
Today I have a list of objects like
Formatacao_RelatorioLinhaDeletada
and perform a foreach on this list, picking item by item giving the attach and saving the modifications in the bank according to the code below:
db.Formatacao_RelatorioLinhaDeletada.Attach(obj);
db.Entry<Formatacao_RelatorioLinhaDeletada>(obj).State = EntityState.Modified;
return (db.SaveChanges() > 0);
I wonder if I can perform an entire list attach as if we were running an SQL as below that updates multiple records with a single Update:
UPDATE TABELA SET a = 2 WHERE TESTE > 0
I await the discussion of the people but already thank!
there are ways to do this, one is with Pure SQL by
Entity Framework
, another is to bring the data and changing the list giving aSavingChanges()
if few records work well, everything depends on contexts if you can say something else, how you bring the list, how many records comes, want to create a method and solve this problem basically with pure SQL?– novic
The list comes with many records however it is exactly the table template in Entity
– Arthur Zanini