/// <summary> /// Builds the name of the property. /// Default logic, for <see cref="EntityPropertyNameBuilder"/>. /// </summary> /// <param name="propertyDataObject">Property of the data object.</param> /// <returns>The name of appropriate EDM property.</returns> private string BuildEntityPropertyName(PropertyInfo propertyDataObject) { PublishNameAttribute attr = propertyDataObject.GetCustomAttribute <PublishNameAttribute>(true); if (attr != null) { return(attr.TypePublishName); } return(propertyDataObject.Name); }
/// <summary> /// Builds the name of the entity set. /// Default logic, for <see cref="EntitySetNameBuilder"/>. /// </summary> /// <param name="dataObjectType">Type of the data object.</param> /// <returns>The name of appropriate EDM entity set.</returns> private string BuildEntitySetName(Type dataObjectType) { PublishNameAttribute attr = dataObjectType.GetCustomAttribute <PublishNameAttribute>(false); if (attr != null && !string.IsNullOrEmpty(attr.EntitySetPublishName)) { return(attr.EntitySetPublishName); } string typeName = BuildEntityTypeName(dataObjectType); string nameSpace = BuildEntityTypeNamespace(dataObjectType); return(string.Concat(_useNamespaceInEntitySetName ? $"{nameSpace}.{typeName}".Replace(".", string.Empty) : typeName, "s" /* "Aliases"*/).Replace("_", string.Empty)); //return string.Concat(_useNamespaceInEntitySetName ? dataObjectType.FullName.Replace(".", string.Empty) : dataObjectType.Name, "s"/* "Aliases"*/).Replace("_", string.Empty); }
/// <summary> /// Builds the namespace of the entity. /// Default logic, for <see cref="EntityTypeNamespaceBuilder"/>. /// </summary> /// <param name="dataObjectType">Type of the data object.</param> /// <returns>The namespace of appropriate EDM entity.</returns> private string BuildEntityTypeNamespace(Type dataObjectType) { PublishNameAttribute attr = dataObjectType.GetCustomAttribute <PublishNameAttribute>(false); if (attr != null) { int lastPos = attr.TypePublishName.LastIndexOf("."); if (lastPos < 0) { return(string.Empty); } return(attr.TypePublishName.Substring(0, lastPos)); } return(dataObjectType.Namespace); }