Quantcast
Channel: WCF Data Services forum
Viewing all articles
Browse latest Browse all 877

Best way to handle empty bags/collections (OData v.3)

$
0
0

Hi,

Collection properties that are exposed via OData must not empy. If a property is defined in a schema as a collection, then an attempt to pass an empty array results in exception:

"OData The collection property has a null value. Collection properties that return a null value are not supported."

There must be some technical reasons behind this constrains, but unfortunately it's very common for a collection to be empty. So this constraint becomes an obstacle to expose real-world data via OData protocol

The question at large: are there any plans to lift this restriction?

The more practical question: how to make a workaround?

When it comes to workarounds, the only one I can think of is to wrap a collection into a nullable complex type: e.g. if you have a complex type Person with a collection of Phones revise it so Person contains a complex type PhoneCollection that in turn contains a collection of Phones. When a person has no phones, PhoneCollection is null.

I didn't try to implement it yet, just wanted to check it first in the community. Is this a right strategy to solve OData nullable collection problem?


Vagif Abilov


Viewing all articles
Browse latest Browse all 877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>