Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Unassigned: [OData] Deserialization should fail when a required field is not present on the Payload [1175]

$
0
0
Having an entity like the following:

```
public class UntypedCustomer
{
public int Id { get; set; }
public string Name { get; set; }
public virtual IList<UntypedOrder> Orders { get; set; }
public virtual IList<UntypedAddress> Addresses { get; set; }
public virtual IList<int> FavoriteNumbers { get; set; }
}
```

and a service that defines an entity set of entities with a required property:
```
ODataModelBuilder builder = new ODataConventionModelBuilder();
var customers = builder.EntitySet<UntypedCustomer>("UntypedCustomers");
customers.EntityType.Property(c => c.Name).IsRequired();
```
when the user sends a payload without the required field:
```
{
"Id": 10,
"Orders": [],
"Addresses": [],
"FavoriteNumbers": []
}
```
the deserialization should fail instead of assigning the default value to the field.

Viewing all articles
Browse latest Browse all 7215

Trending Articles