public static string GetClrPropertyName(IEdmProperty edmProperty, IEdmModel edmModel) { if (edmProperty == null) { throw Error.ArgumentNull("edmProperty"); } if (edmModel == null) { throw Error.ArgumentNull("edmModel"); } string propertyName = edmProperty.Name; ClrPropertyInfoAnnotation annotation = edmModel.GetAnnotationValue <ClrPropertyInfoAnnotation>(edmProperty); if (annotation != null) { PropertyInfo propertyInfo = annotation.ClrPropertyInfo; if (propertyInfo != null) { propertyName = propertyInfo.Name; } } return(propertyName); }
public static string GetClrPropertyName(IEdmProperty edmProperty, IEdmModel edmModel) { if (edmProperty == null) { throw Error.ArgumentNull("edmProperty"); } if (edmModel == null) { throw Error.ArgumentNull("edmModel"); } string propertyName = edmProperty.Name; ClrPropertyInfoAnnotation annotation = edmModel.GetAnnotationValue <ClrPropertyInfoAnnotation>(edmProperty); if (annotation != null) { PropertyInfo propertyInfo = annotation.ClrPropertyInfo; if (propertyInfo != null) { propertyName = propertyInfo.Name; if (annotation.PropertiesPath != null && annotation.PropertiesPath.Any()) { propertyName = string.Join("", annotation.PropertiesPath.Select(p => p.Name + "\\")) + propertyName; } } } return(propertyName); }
/// <summary> /// Get the CLR property name. /// </summary> /// <param name="edmModel">The Edm model.</param> /// <param name="edmProperty">The Edm property.</param> /// <returns>The property name.</returns> public static string GetClrPropertyName(this IEdmModel edmModel, IEdmProperty edmProperty) { if (edmModel == null) { throw new ArgumentNullException(nameof(edmModel)); } if (edmProperty == null) { throw new ArgumentNullException(nameof(edmProperty)); } string propertyName = edmProperty.Name; ClrPropertyInfoAnnotation annotation = edmModel.GetAnnotationValue <ClrPropertyInfoAnnotation>(edmProperty); if (annotation != null) { PropertyInfo propertyInfo = annotation.ClrPropertyInfo; if (propertyInfo != null) { propertyName = propertyInfo.Name; } } return(propertyName); }
private PropertyInfo GetPropertyInfo(IEdmProperty property) { ClrPropertyInfoAnnotation clrPropertyAnnotation = _model.GetAnnotationValue <ClrPropertyInfoAnnotation>(property); if (clrPropertyAnnotation != null) { return(clrPropertyAnnotation.ClrPropertyInfo); } ClrTypeAnnotation clrTypeAnnotation = _model.GetAnnotationValue <ClrTypeAnnotation>(property.DeclaringType); Contract.Assert(clrTypeAnnotation != null); PropertyInfo info = clrTypeAnnotation.ClrType.GetProperty(property.Name); Contract.Assert(info != null); return(info); }