src/Misc/EFTools/EntityDesignModel/ModelHelper.cs
/// <summary>
///     Compare if an entity model property is equivalent to the schema column.
///     The comparison will check that the types are equivalent and that the following facets match:
///     - Nullable
///     - Size
///     - Scale
///     - Precision
/// </summary>
/// <param name="storageModel"></param>
/// <param name="property"></param>
/// <param name="column"></param>
/// <returns></returns>
Compare if an entity model property is equivalent to the schema column.
The comparison will check that the types are equivalent and that the following facets match:
Nullable
Size
Scale
Precision
Compare if an entity model property is equivalent to the schema column . The comparison will check that the types are equivalent and that the following facets match : Nullable Size Scale Precision
internal static bool IsPropertyEquivalentToSchemaColumn(
            StorageEntityModel storageModel, Property property, IRawDataSchemaColumn column)
        {
            Debug.Assert(column != null, "The passed in data schema column is null");
            Debug.Assert(property != null, "The passed in entity property column is null");
            if (column != null
                && property != null)
            {
                var columnPrimitiveType = GetPrimitiveType(storageModel, column.NativeDataType, column.ProviderDataType);
                var propertyPrimitiveType = GetPrimitiveTypeFromString(property.TypeName);
                if (columnPrimitiveType == null)
                {
                    return false;
                }
                if (propertyPrimitiveType == null)
                {
                    return false;
                }
                if (columnPrimitiveType.ClrEquivalentType != propertyPrimitiveType.ClrEquivalentType)
                {
                    return false;
                }
                if (BoolOrNoneComparison.Equal != property.Nullable.CompareToUsingDefault(column.IsNullable))
                {
                    return false;
                }
                if (column.Size != null
                    && GetMaxLengthFacetText(column.Size) != property.MaxLength.Value.ToString())
                {
                    return false;
                }
                if (column.Scale != null
                    && column.Scale.Value != property.Scale.GetAsNullableUInt())
                {
                    return false;
                }
                if (column.Precision != null
                    && column.Precision.Value != property.Precision.GetAsNullableUInt())
                {
                    return false;
                }
            }
            return true;
        }
internal static bool IsPropertyEquivalentToSchemaColumn ( StorageEntityModel storageModel , Property property , IRawDataSchemaColumn column ) { Debug . Assert ( column != null , " " ) ; Debug . Assert ( property != null , " " ) ; if ( column != null && property != null ) { var columnPrimitiveType = GetPrimitiveType ( storageModel , column . NativeDataType , column . ProviderDataType ) ; var propertyPrimitiveType = GetPrimitiveTypeFromString ( property . TypeName ) ; if ( columnPrimitiveType == null ) { return false ; } if ( propertyPrimitiveType == null ) { return false ; } if ( columnPrimitiveType . ClrEquivalentType != propertyPrimitiveType . ClrEquivalentType ) { return false ; } if ( BoolOrNoneComparison . Equal != property . Nullable . CompareToUsingDefault ( column . IsNullable ) ) { return false ; } if ( column . Size != null && GetMaxLengthFacetText ( column . Size ) != property . MaxLength . Value . ToString ( ) ) { return false ; } if ( column . Scale != null && column . Scale . Value != property . Scale . GetAsNullableUInt ( ) ) { return false ; } if ( column . Precision != null && column . Precision . Value != property . Precision . GetAsNullableUInt ( ) ) { return false ; } } return true ; }
Compare if an entity model property is equivalent to the schema column.
Compare if an entity model property is equivalent to the schema column .
// if columnPrimitiveType is null, this could be because the column type is unsupported. // if propertyPrimitiveType is null, this could be because the property is a complex property. // check their CLR equivalent type. // Check Nullable attribute // Check MaxLength/size attribute. // Check Scale attribute // Check Precision attribute
None
storageModel
StorageEntityModel
None
property
Property
None
column
IRawDataSchemaColumn
None