JOB LINQ to update values in the database!

Asked

Viewed 34 times

0

I have a JOB in which I need to update all the values to the maximum value that exists for a column, but my code is not working. Can someone help me?

My code:

List<SqlOnlyCostModel> costat = new List<SqlOnlyCostModel>();
foreach (var QuantityItem in all)
{
    int maxQtd = all.Max(x => x.QuantityItem);
    decimal maxPrice = all.Max(x => x.UnitPrice);
    string nCurrency = all.Max(x => x.Currency);
    string nCost = all.Max(x => x.Currency);
}

_dbEngContext.SaveChanges();
  • 3

    Lucas, translate your question into English!

1 answer

0

Considering that you are using a Model for these assigned values, it would be something like:

//Your code
Context.Entry(ModelName).State = EntityState.Modified;
Context.SaveChanges();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.