src/Misc/EFTools/EntityDesignModel/Commands/CreateMatchingFunctionImportCommand.cs
/// <summary>
///     Add commands to create and set the facets for a new complex type property to match the column.
/// </summary>
Add commands to create and set the facets for a new complex type property to match the column.
Add commands to create and set the facets for a new complex type property to match the column .
internal static void AddCreateComplexTypePropertyCommands(
            StorageEntityModel storageModel, IRawDataSchemaColumn column, CreateComplexTypeCommand cmdNewComplexType,
            ComplexType complexType, IList<Command> commands)
        {
            Debug.Assert(
                ((cmdNewComplexType != null && complexType == null) || (cmdNewComplexType == null && complexType != null)),
                "Both cmdNewComplexType and complexType are null or both are not null. cmdNewComplexType is null : "
                + (cmdNewComplexType == null).ToString() + ", complexType is null : " + (complexType == null).ToString());
            if ((cmdNewComplexType != null && complexType == null)
                || (cmdNewComplexType == null && complexType != null))
            {
                if (column.ProviderDataType != -1)
                {
                    var primitiveType = ModelHelper.GetPrimitiveType(storageModel, column.NativeDataType, column.ProviderDataType);
                    if (primitiveType != null)
                    {
                        CreateComplexTypePropertyCommand cmdNewComplexTypeProperty = null;
                        if (cmdNewComplexType != null)
                        {
                            cmdNewComplexTypeProperty = new CreateComplexTypePropertyCommand(
                                ModelHelper.CreateValidSimpleIdentifier(column.Name),
                                cmdNewComplexType,
                                primitiveType.GetEdmPrimitiveType().Name,
                                column.IsNullable);
                            commands.Add(cmdNewComplexTypeProperty);
                        }
                        else
                        {
                            cmdNewComplexTypeProperty = new CreateComplexTypePropertyCommand(
                                ModelHelper.CreateValidSimpleIdentifier(column.Name),
                                complexType,
                                primitiveType.GetEdmPrimitiveType().Name,
                                column.IsNullable);
                            commands.Add(cmdNewComplexTypeProperty);
                        }
                        var cmdSetPropertyFacets = new SetPropertyFacetsCommand(
                            cmdNewComplexTypeProperty
                            , null 
                            , ModelHelper.GetMaxLengthFacetValue(column.Size)
                            , null 
                            , DefaultableValueUIntOrNone.GetFromNullableUInt(column.Precision)
                            , DefaultableValueUIntOrNone.GetFromNullableUInt(column.Scale)
                            , null 
                            , null 
                            , null 
                            );
                        commands.Add(cmdSetPropertyFacets);
                    }
                }
            }
        }
internal static void AddCreateComplexTypePropertyCommands ( StorageEntityModel storageModel , IRawDataSchemaColumn column , CreateComplexTypeCommand cmdNewComplexType , ComplexType complexType , IList < Command > commands ) { Debug . Assert ( ( ( cmdNewComplexType != null && complexType == null ) || ( cmdNewComplexType == null && complexType != null ) ) , " " + ( cmdNewComplexType == null ) . ToString ( ) + " " + ( complexType == null ) . ToString ( ) ) ; if ( ( cmdNewComplexType != null && complexType == null ) || ( cmdNewComplexType == null && complexType != null ) ) { if ( column . ProviderDataType != - 1 ) { var primitiveType = ModelHelper . GetPrimitiveType ( storageModel , column . NativeDataType , column . ProviderDataType ) ; if ( primitiveType != null ) { CreateComplexTypePropertyCommand cmdNewComplexTypeProperty = null ; if ( cmdNewComplexType != null ) { cmdNewComplexTypeProperty = new CreateComplexTypePropertyCommand ( ModelHelper . CreateValidSimpleIdentifier ( column . Name ) , cmdNewComplexType , primitiveType . GetEdmPrimitiveType ( ) . Name , column . IsNullable ) ; commands . Add ( cmdNewComplexTypeProperty ) ; } else { cmdNewComplexTypeProperty = new CreateComplexTypePropertyCommand ( ModelHelper . CreateValidSimpleIdentifier ( column . Name ) , complexType , primitiveType . GetEdmPrimitiveType ( ) . Name , column . IsNullable ) ; commands . Add ( cmdNewComplexTypeProperty ) ; } var cmdSetPropertyFacets = new SetPropertyFacetsCommand ( cmdNewComplexTypeProperty , null , ModelHelper . GetMaxLengthFacetValue ( column . Size ) , null , DefaultableValueUIntOrNone . GetFromNullableUInt ( column . Precision ) , DefaultableValueUIntOrNone . GetFromNullableUInt ( column . Scale ) , null , null , null ) ; commands . Add ( cmdSetPropertyFacets ) ; } } } }
Add commands to create and set the facets for a new complex type property to match the column.
Add commands to create and set the facets for a new complex type property to match the column .
// Assert if both cmdNewComplexType and complexType are null or if both are not null. // Skip creating the complex type property for a column if the column type is unknown or not supported ( providerDataType == -1 ). // We only create complex type property if primitive type is known. // if complex type is not created yet. // Automatically "fix" the property Name if it contains bad character.  // We need to do this since we don't let the user to change the property name from the Function Import dialog. // Automatically "fix" the property Name if it contains bad character.  // We need to do this since we don't let the user to change the property name from the Function Import dialog. // We only update the facets that are displayed in Function Import dialog return type view list: // - Nullable. // - Max Size. // - Precision. // - Scale. // Default value // Fixed Length // unicode // collation // concurrency mode 
storageModel
StorageEntityModel
column
IRawDataSchemaColumn
cmdNewComplexType
CreateComplexTypeCommand
complexType
ComplexType
commands
IList<Command>