private static T GetPropertyValue <T>(this IEdmModel model, IEdmStructuredValue context, IEdmEntityType contextType, IEdmValueTerm term, IEdmProperty property, string qualifier, Func <IEdmExpression, IEdmStructuredValue, T> evaluator) { IEnumerable <IEdmValueAnnotation> annotations = model.FindVocabularyAnnotations <IEdmValueAnnotation>(contextType, term, qualifier); if (annotations.Count() != 1) { throw new InvalidOperationException("Type " + contextType.ToTraceString() + " must have a single annotation with term " + term.ToTraceString()); } var annotationValue = annotations.Single().Value as IEdmRecordExpression; if (annotationValue == null) { throw new InvalidOperationException("Type " + contextType.ToTraceString() + " must have a single annotation containing a record expression with term " + term.ToTraceString()); } var propertyConstructor = annotationValue.FindProperty(property.Name); return(propertyConstructor != null?evaluator(propertyConstructor.Value, context) : default(T)); }