Skip to content

Retail Proxy (C#) entity creation error / serialization issue. #378

@Dwizzle252

Description

@Dwizzle252

Retail Proxy (C#) Issue during entity creation

Summary

Describe the issue
Attempting to create a customer through the retail proxy > RetailServerContext > CustomerManager.

When creating a customer, I get an error "(A null value was found for the property named 'AccountNumber', which has the expected type 'Edm.String[Nullable=False]'" - however I have left that property off when configuring the customer."

This property was not set when populating in the new customer object. I think the retail proxy/server context is serializing the whole customer object instead of just the properties that have been set or changed.

var manager = _managerFactory.GetManager<ICustomerManager>();

 var customer = new Customer()
 {
   //only setting the properties I want  created for the customer.
};

//this results in the error (seen in event viewer logs for the retail server)
customer = await manager.Create(customer);

If calling: customer.SerializeToJsonObject(); the serialization occurs correctly, however this serialization is ignored in the RetailServerContext and underlying data service context.

I assume this occurs with all the retail proxy create calls & not just customer.

Version and Error Info
Sample Version:
9.54.25212.2 - Microsoft.Dynamics.Commerce.Proxy.ScaleUnit
10.0.44 - Commerce Scale Unit (SEALED)

Microsoft.OData.ODataException: A null value was found for the property named 'AccountNumber', which has the expected type 'Edm.String[Nullable=False]'. The expected type 'Edm.String[Nullable=False]' does not allow null values.
   at Microsoft.OData.ReaderValidationUtils.ThrowNullValueForNonNullableTypeException(IEdmTypeReference expectedValueTypeReference, String propertyName)
   at Microsoft.OData.ReaderValidationUtils.ValidateNullValueAllowed(IEdmTypeReference expectedValueTypeReference, Boolean validateNullValue, String propertyName, Nullable`1 isDynamicProperty)
   at Microsoft.OData.ReaderValidationUtils.ValidateNullValue(IEdmTypeReference expectedTypeReference, Boolean enablePrimitiveTypeConversion, Boolean validateNullValue, String propertyName, Nullable`1 isDynamicProperty)
   at Microsoft.OData.ReaderValidator.ValidateNullValue(IEdmTypeReference expectedTypeReference, Boolean validateNullValue, String propertyName, Nullable`1 isDynamicProperty)
   at Microsoft.OData.Json.ODataJsonReaderCoreUtils.TryReadNullValue(IJsonReader jsonReader, ODataInputContext inputContext, IEdmTypeReference expectedTypeReference, Boolean validateNullValue, String propertyName, Nullable`1 isDynamicProperty)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions