// <summary> // Return the corresponding FunctionImport's result-column name for a given property. // </summary> internal static string GetFunctionImportResultColumnName(EntityModel.FunctionImport functionImport, EntityModel.Property property) { if (functionImport != null) { var columnName = EntityModel.FunctionImport.GetFunctionImportResultColumnName(functionImport, property); if (!String.IsNullOrEmpty(columnName)) { return(columnName); } } return(property.LocalName.Value); }
private ListViewItem CreateReturnTypeShapeListItem(IDataSchemaColumn column, EntityProperty property, string action) { var storageModel = _container.Artifact.StorageModel(); Debug.Assert(storageModel != null, "Storage model is null"); Debug.Assert(column != null || property != null, "Both data schema column and complex type property is null"); ListViewItem item = null; var isUpdateMode = false; if (column != null || property != null) { PrimitiveType columnPrimitiveType = null; // Retrieve column primitive type if (column != null && column.ProviderDataType != NotSupportedDataType) { columnPrimitiveType = ModelHelper.GetPrimitiveType(storageModel, column.NativeDataType, column.ProviderDataType); } // if we could not find primitive type for the column, that means the column type is not supported. if (column != null && columnPrimitiveType == null && !String.IsNullOrEmpty(action)) { // overwrite the action column. action = DialogsResource.NewFunctionImportDialog_ReturnTypeListNoAction; } // if action is null or string empty, the first column is the column name. if (String.IsNullOrEmpty(action)) { item = new ListViewItem(column != null ? column.Name : property.LocalName.Value); } else { item = new ListViewItem(action); item.SubItems.Add(column != null ? column.Name : property.LocalName.Value); isUpdateMode = action == DialogsResource.NewFunctionImportDialog_ReturnTypeListUpdateAction; } PrimitiveType propertyPrimitiveType = null; if (property != null) { propertyPrimitiveType = ModelHelper.GetPrimitiveTypeFromString(property.TypeName); } // Edm Type Name // if we could not find primitive type for the column, that means the column type is not supported. if (column != null && columnPrimitiveType == null) { item.SubItems.Add(DialogsResource.NewFunctionImportDialog_NotSupportedColumnType); } else { item.SubItems.Add( GetReturnTypeListViewCellText( isUpdateMode , (propertyPrimitiveType != null ? propertyPrimitiveType.GetEdmPrimitiveType().Name : null) , (columnPrimitiveType != null ? columnPrimitiveType.GetEdmPrimitiveType().Name : null))); } // DB Type for the CSDL type property should always be null. item.SubItems.Add( GetReturnTypeListViewCellText( false , null , (columnPrimitiveType != null ? columnPrimitiveType.Name : null))); // Nullable item.SubItems.Add( GetReturnTypeListViewCellText( isUpdateMode , (property != null ? GetColumnNullableFacetText(property.Nullable) : null) , (column != null ? GetColumnNullableFacetText(column.IsNullable) : null))); // Size string propertySize = null; if (property != null && ModelHelper.IsValidModelFacet(property.TypeName, EntityProperty.AttributeMaxLength) && property.MaxLength != null && property.MaxLength.Value != null) { propertySize = property.MaxLength.Value.ToString(); } item.SubItems.Add( GetReturnTypeListViewCellText( isUpdateMode, propertySize , (column != null ? ModelHelper.GetMaxLengthFacetText(column.Size) : null))); // Precision string propertyPrecision = null; if (property != null && ModelHelper.IsValidModelFacet(property.TypeName, EntityProperty.AttributePrecision) && property.Precision != null) { propertyPrecision = property.Precision.Value.ToString(); } item.SubItems.Add( GetReturnTypeListViewCellText( isUpdateMode, propertyPrecision , (column != null && column.Precision != null ? column.Precision.ToString() : null))); // Scale string propertyScale = null; if (property != null && ModelHelper.IsValidModelFacet(property.TypeName, EntityProperty.AttributeScale) && property.Scale != null) { propertyScale = property.Scale.Value.ToString(); } item.SubItems.Add( GetReturnTypeListViewCellText( isUpdateMode, propertyScale , (column != null && column.Scale != null ? column.Scale.ToString() : null))); } return item; }