I'm trying to access OData from C# using this VS extension this VS extension (which seems to be the recommended way). It generates a Connected service inside the project, to access (in my case) a Business Central API.
When I create an object (here a vendor), through this kind of code,
var context = new BCNS.NAV(new Uri(_serviceRoot));
var vendor = Vendor.CreateVendor(Guid.NewGuid());
context.AddToVendors(vendor);
context.SaveChanges();
it fails because 2 of the properties of vendore are read-only; the context sends every property in the serialized json and it fails. (if I remove them by hand it succeeds)
These 2 properties don't look different in the $metadata:
<Property Name="balance" Type="Edm.Decimal" Scale="Variable" />
<Property Name="lastModifiedDateTime" Type="Edm.DateTimeOffset" />
Don't jnow how it could guess they are readonly.
I've seen here how to send a partial payload during an update request, and I am desperately trying to make similar thing for a creation.
I saw there is a possible parameter "PostOnlySetProperties" for context.SaveChanges that "can only be used when using DataServiceCollection", but I fail trying to add an object through it. It seems to handle only objects it's tracking, not new ones.
Would someone know how to send a partial payload when creating a new item ?
Thanks in advance.