We use Linq2DB ORM library for our .NET ORM models see https://github.com/linq2db/linq2db
How to send update with only changed columns? Now the SQL query includes all of the columns and values
Currently there is no mechanism for tracking changes in the object level to update only the changed properties but if you know what columns are changed, you can use the set function in conjunction with the update function to do the partial updates (just like the example given in the github page )
using (var db = new DbNorthwind())
{
db.Product
.Where(p => p.ProductID == product.ProductID)
.Set(p => p.Name, product.Name)
.Set(p => p.UnitPrice, product.UnitPrice)
.Update();
}
First of all, linq2db is a lightweight ORM. What means it doesn't have heavy context and it doesn't know anything about changes in entities and never will-if you want to have change tracking than use Entity Framework or NHibernate. So you have to implement change tracking yourself (if you really need it) or update the whole entity(like you did). If you know updated column you can use any syntax provided (see Linq2Db crud operations). If you know only changed column names-you can dynamically construct linq expressions and use one of syntaxes Linq2Db crud operations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With