Bag/Collection Support in OData Library

Topics: General, OData Library, WCF Data Services
Sep 27, 2012 at 2:24 PM

Hello All, 

From one of the posts, I came to know that Bag/Collection data is supported. "ODataCollectionValue" class can be used for that. I tried to do that but in my case reading metadata fails (basically I am doing this first to get EdmModel) when bag/Collection data type is involved. 

For example, actual data contains something like below:

<d:Version m:type="Bag(Edm.Int32)">
					<d:element>11</d:element>
					<d:element>0</d:element>
					<d:element>0</d:element>
					<d:element>0</d:element>
				</d:Version>

and metadata for the same is something like below:
<Property Name="Version" Type="Bag(Edm.Int32)"...

I am referring to one of the microsoft example to see if it works. This 
example reads metadata in following way:
HTTPClientRequestMessage message = new HTTPClientRequestMessage(oDataServiceURI + METADATA);

            message.SetHeader("Accept", "application/xml");
            message.SetHeader("DataServiceVersion", ODataUtils.ODataVersionToString(ODataVersion.V2));            message.SetHeader("MaxDataServiceVersion", ODataUtils.ODataVersionToString(ODataVersion.V3));            using (ODataMessageReader messageReader = new ODataMessageReader(message.GetResponse(), customSettings))            
	
               edmmodel = messageReader.ReadMetadataDocument();            
	    }
I get following error on "ReadMetadataDocument()" method:

"InvalidTypeName : The type name 'Bag(Edm.Int32)' is invalid. The type name must be that of a primitive type, a fully qualified name or an inline 'Collection' or 'Ref' type."

Please let me know what is this about? Do we need to change anything at server side?
May be Collection(Edm.Int32) instead of Bag(Edm.Int32).

Please suggest.

Thanks,
Viral Thakkar

Editor
Sep 27, 2012 at 2:48 PM

The "Bag" was renamed to "Collection" for the official release of OData V3. So the correct type name is Collection(Edm.Int32).

Thanks,

Sep 27, 2012 at 3:20 PM

Hi,

Thanks a lot for your quick reply.

Regards,

Viral Thakkar