Is there a way to send a property with defaultValue but update it with the database computed result? There's a trigger in database, that for input -1 triggers a procedure which computes a new value. How to get the value back?
<Property Name="ID" Type="int" Nullable="false" StoreGeneratedPattern="None" DefaultValue="-1" />
var x = new Stuff();
db.Stuff.AddObject(x);
db.SaveChanges();
return x.ID //gives -1, but the computed value should be different.
If you are using EF core it could be like this:
public int CreateMyEntity(MyEntityType myEntity)
{
Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<MyEntityType> created = _context.MyEntityType.Add(myEntity);
_context.SaveChanges()
return created.Entity.Id;
}
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