Using NPoco, I'm trying to figure out how to update more than one column of an object (but not all of them). This works...
db.Update(item, new[] { "status", "tracking_number", "updated_at" });
...but I'm trying to use the notation below so I can use my object's property names rather than the database column names.
int Update<T>(T poco, Expression<Func<T, object>> fields);
How do I list more than one column using the above syntax? This will update a single column but I assume I can list more than one but I can't figure out the notation.
db.Update(item, i => i.Status);
Looking through the code, it seems you use an anonymous object:
x => x.SomeProperty1 or x => new{ x.SomeProperty1, x.SomeProperty2}
so in your example:
db.Update(item, i => new { i.Status, i.TrackingNumber, i.UpdatedAt });
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