simple-odata-client / Simple.OData.Client

MIT License
329 stars 196 forks source link

Question: Is there a way to obtain annotations on an entity contained in the metadata #544

Open toryb opened 5 years ago

toryb commented 5 years ago

For example, Microsoft Dynamics 365 Customer Engagement (CRM) uses the OData.Community.Keys.V1.AlternateKeys annotation term to define a property as an AlternateKey. I would like to have access to that information.

I'm not necessarily making a feature request, just asking if there is some existing way to access the annotation data for an entity that is in the metadata without getting / parsing the metadata myself.

Thanks.

object commented 5 years ago

Sorry for the late response. Currently it's not possible to access all entity annotations. Some of them (needed by the library itself) are parsed and kept, others are stripped away. Several people asked for this feature, but it's not implemented yet.

pko67 commented 5 years ago

I would like to retrieve the annotation data. When I see the requested annotations in Visual Studio Debugger, is there a way using the API to retrieve these data?

Code: var metadata = await client.GetMetadataAsync();

Debugger watching tool: metadata.schemaTypeDictionary.Items[6].value.DeclaredProperties[2].@property.annotations.Items[0].value

When I grab the debugger value to evaluate it as a single line, it will show me the following error:

((Microsoft.Data.Edm.Csdl.Internal.Parsing.Ast.CsdlDirectValueAnnotation) (new System.Collections.Generic.Mscorlib_CollectionDebugView((( (Microsoft.Data.Edm.Csdl.Internal.CsdlSemantics.CsdlSemanticsProperty) (new System.Collections.Generic.Mscorlib_CollectionDebugView(( (Microsoft.Data.Edm.Csdl.Internal.CsdlSemantics.CsdlSemanticsStructuredTypeDefinition) (new System.Collections.Generic.Mscorlib_DictionaryDebugView<string, Microsoft.Data.Edm.IEdmSchemaType>(( (Microsoft.Data.Edm.Library.EdmModelBase)metadata).schemaTypeDictionary).Items[6]).value).DeclaredProperties).Items[2])).@property).annotations).Items[0])).value

error CS1503: Argument "1": Conversion of "System.Collections.Generic.IEnumerable" in "System.Collections.Generic.ICollection" impossible

Thank you! Peter