src/Misc/EFTools/EntityDesign/UI/Views/Dialogs/NewFunctionImportDialog.cs
// <summary>
//     Helper function to create an item row in return type list view.
// </summary>
Helper function to create an item row in return type list view.
Helper function to create an item row in return type list view .
[SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
        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;
                if (column != null
                    && column.ProviderDataType != NotSupportedDataType)
                {
                    columnPrimitiveType = ModelHelper.GetPrimitiveType(storageModel, column.NativeDataType, column.ProviderDataType);
                }
                if (column != null
                    && columnPrimitiveType == null
                    && !String.IsNullOrEmpty(action))
                {
                    action = DialogsResource.NewFunctionImportDialog_ReturnTypeListNoAction;
                }
                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);
                }
                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)));
                }
                item.SubItems.Add(
                    GetReturnTypeListViewCellText(
                        false
                        , null
                        , (columnPrimitiveType != null ? columnPrimitiveType.Name : null)));
                item.SubItems.Add(
                    GetReturnTypeListViewCellText(
                        isUpdateMode
                        , (property != null ? GetColumnNullableFacetText(property.Nullable) : null)
                        , (column != null ? GetColumnNullableFacetText(column.IsNullable) : null)));
                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)));
                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)));
                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;
        }
[ SuppressMessage ( " " , " " ) ] private ListViewItem CreateReturnTypeShapeListItem ( IDataSchemaColumn column , EntityProperty property , string action ) { var storageModel = _container . Artifact . StorageModel ( ) ; Debug . Assert ( storageModel != null , " " ) ; Debug . Assert ( column != null || property != null , " " ) ; ListViewItem item = null ; var isUpdateMode = false ; if ( column != null || property != null ) { PrimitiveType columnPrimitiveType = null ; if ( column != null && column . ProviderDataType != NotSupportedDataType ) { columnPrimitiveType = ModelHelper . GetPrimitiveType ( storageModel , column . NativeDataType , column . ProviderDataType ) ; } if ( column != null && columnPrimitiveType == null && ! String . IsNullOrEmpty ( action ) ) { action = DialogsResource . NewFunctionImportDialog_ReturnTypeListNoAction ; } 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 ) ; } 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 ) ) ) ; } item . SubItems . Add ( GetReturnTypeListViewCellText ( false , null , ( columnPrimitiveType != null ? columnPrimitiveType . Name : null ) ) ) ; item . SubItems . Add ( GetReturnTypeListViewCellText ( isUpdateMode , ( property != null ? GetColumnNullableFacetText ( property . Nullable ) : null ) , ( column != null ? GetColumnNullableFacetText ( column . IsNullable ) : null ) ) ) ; 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 ) ) ) ; 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 ) ) ) ; 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 ; }
Helper function to create an item row in return type list view.
Helper function to create an item row in return type list view .
// Retrieve column primitive type // if we could not find primitive type for the column, that means the column type is not supported. // overwrite the action column. // if action is null or string empty, the first column is the column name. // Edm Type Name // if we could not find primitive type for the column, that means the column type is not supported. // DB Type for the CSDL type property should always be null. // Nullable // Size // Precision // Scale
column
IDataSchemaColumn
property
EntityProperty
action
string