How to iterate OData metadata? I need to iterate all entities, their properties with types, keys and navigation properties (all available information to be precise), but I got stuck since SchemaElements returns objects of internal types (Microsoft.OData.Edm.Csdl.CsdlSemantics.CsdlSemanticsEntityContainer) and I cannot cast them to get all this information.
var metadata = await _client.GetMetadataAsync();
foreach (var element in metadata.SchemaElements)
where client is declared this way:
Simple.OData.Client.ODataClient _client;
After installing https://marketplace.visualstudio.com/items?itemName=bingl.ODatav4ClientCodeGenerator add new item, T4 code of that file, iterate almost all aspects of $metadata to generate c# odata proxy for you, you can use those codes to find your way
If you can use https://www.nuget.org/packages/Microsoft.OData.Client/6.5.0 (note: this library is for OData v4 only), for v3 use https://www.nuget.org/packages/Microsoft.Data.OData/.
ODataServiceDocument has property EntitySets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With