EFIngresProvider/EFIngresProviderManifest.cs
/// <summary>
/// This method takes a type and a set of facets and returns the best mapped equivalent type 
/// in Ingres, taking the store version into consideration.
/// </summary>
/// <param name="storeType">A TypeUsage encapsulating an EDM type and a set of facets</param>
/// <returns>A TypeUsage encapsulating a store type and a set of facets</returns>
This method takes a type and a set of facets and returns the best mapped equivalent type
in Ingres, taking the store version into consideration.
This method takes a type and a set of facets and returns the best mapped equivalent type in Ingres taking the store version into consideration .
public override TypeUsage GetStoreType(TypeUsage edmType)
        {
            if (edmType == null)
            {
                throw new ArgumentNullException("edmType");
            }
            Debug.Assert(edmType.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType);
            var primitiveType = edmType.EdmType as PrimitiveType;
            if (primitiveType == null)
            {
                throw new ArgumentException(String.Format("The underlying provider does not support the type '{0}'.", edmType));
            }
            ReadOnlyMetadataCollection<Facet> facets = edmType.Facets;
            switch (primitiveType.PrimitiveTypeKind)
            {
                case PrimitiveTypeKind.Boolean:
                    return TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType["tinyint"]);
                case PrimitiveTypeKind.SByte:
                    return TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType["tinyint"]);
                case PrimitiveTypeKind.Byte:
                    return TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType["smallint"]);
                case PrimitiveTypeKind.Int16:
                    return TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType["smallint"]);
                case PrimitiveTypeKind.Int32:
                    return TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType["integer"]);
                case PrimitiveTypeKind.Int64:
                    return TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType["bigint"]);
                case PrimitiveTypeKind.Double:
                    return TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType["float"]);
                case PrimitiveTypeKind.Single:
                    return TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType["real"]);
                case PrimitiveTypeKind.Decimal: 
                    return TypeUsage.CreateDecimalTypeUsage(StoreTypeNameToStorePrimitiveType["decimal"], TypeHelpers.GetPrecision(edmType, 18), TypeHelpers.GetScale(edmType, 0));
                case PrimitiveTypeKind.Binary: 
                    {
                        var isFixedLength = facets["FixedLength"].GetValue<bool>(false);
                        var maxLengthFacet = facets["MaxLength"];
                        var maxLength = maxLengthFacet.GetValue<int?>();
                        if (maxLengthFacet.IsUnbounded || maxLength == null || maxLength.Value > binaryMaxSize)
                        {
                            maxLength = null;
                        }
                        var storeTypeName = isFixedLength ? "byte" : maxLength == null ? "long byte" : "byte varying";
                        return CreateBinaryTypeUsage(StoreTypeNameToStorePrimitiveType[storeTypeName], isFixedLength, maxLength);
                    }
                case PrimitiveTypeKind.String: 
                    {
                        var isUnicode = facets["Unicode"].GetValue<bool>(false);
                        var isFixedLength = facets["FixedLength"].GetValue<bool>(false);
                        var maxLengthFacet = facets["MaxLength"];
                        var maxLength = maxLengthFacet.GetValue<int?>();
                        if (maxLengthFacet.IsUnbounded || maxLength == null || maxLength.Value > varcharMaxSize)
                        {
                            maxLength = null;
                        }
                        var storeTypeName = isFixedLength ? "char" : "varchar";
                        storeTypeName = isUnicode ? "n" + storeTypeName : storeTypeName;
                        storeTypeName = (maxLength == null) ? "long " + storeTypeName : storeTypeName;
                        return CreateStringTypeUsage(StoreTypeNameToStorePrimitiveType[storeTypeName], isUnicode, isFixedLength, maxLength);
                    }
                case PrimitiveTypeKind.DateTime: 
                    return TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType["ingresdate"]);
                case PrimitiveTypeKind.Time: 
                    return TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType["time"]);
                default:
                    throw new NotSupportedException(String.Format("There is no store type corresponding to the EDM type '{0}' of primitive type '{1}'.", edmType, primitiveType.PrimitiveTypeKind));
            }
        }
public override TypeUsage GetStoreType ( TypeUsage edmType ) { if ( edmType == null ) { throw new ArgumentNullException ( " " ) ; } Debug . Assert ( edmType . EdmType . BuiltInTypeKind == BuiltInTypeKind . PrimitiveType ) ; var primitiveType = edmType . EdmType as PrimitiveType ; if ( primitiveType == null ) { throw new ArgumentException ( String . Format ( " " , edmType ) ) ; } ReadOnlyMetadataCollection < Facet > facets = edmType . Facets ; switch ( primitiveType . PrimitiveTypeKind ) { case PrimitiveTypeKind . Boolean : return TypeUsage . CreateDefaultTypeUsage ( StoreTypeNameToStorePrimitiveType [ " " ] ) ; case PrimitiveTypeKind . SByte : return TypeUsage . CreateDefaultTypeUsage ( StoreTypeNameToStorePrimitiveType [ " " ] ) ; case PrimitiveTypeKind . Byte : return TypeUsage . CreateDefaultTypeUsage ( StoreTypeNameToStorePrimitiveType [ " " ] ) ; case PrimitiveTypeKind . Int16 : return TypeUsage . CreateDefaultTypeUsage ( StoreTypeNameToStorePrimitiveType [ " " ] ) ; case PrimitiveTypeKind . Int32 : return TypeUsage . CreateDefaultTypeUsage ( StoreTypeNameToStorePrimitiveType [ " " ] ) ; case PrimitiveTypeKind . Int64 : return TypeUsage . CreateDefaultTypeUsage ( StoreTypeNameToStorePrimitiveType [ " " ] ) ; case PrimitiveTypeKind . Double : return TypeUsage . CreateDefaultTypeUsage ( StoreTypeNameToStorePrimitiveType [ " " ] ) ; case PrimitiveTypeKind . Single : return TypeUsage . CreateDefaultTypeUsage ( StoreTypeNameToStorePrimitiveType [ " " ] ) ; case PrimitiveTypeKind . Decimal : return TypeUsage . CreateDecimalTypeUsage ( StoreTypeNameToStorePrimitiveType [ " " ] , TypeHelpers . GetPrecision ( edmType , 18 ) , TypeHelpers . GetScale ( edmType , 0 ) ) ; case PrimitiveTypeKind . Binary : { var isFixedLength = facets [ " " ] . GetValue < bool > ( false ) ; var maxLengthFacet = facets [ " " ] ; var maxLength = maxLengthFacet . GetValue < int ? > ( ) ; if ( maxLengthFacet . IsUnbounded || maxLength == null || maxLength . Value > binaryMaxSize ) { maxLength = null ; } var storeTypeName = isFixedLength ? " " : maxLength == null ? " " : " " ; return CreateBinaryTypeUsage ( StoreTypeNameToStorePrimitiveType [ storeTypeName ] , isFixedLength , maxLength ) ; } case PrimitiveTypeKind . String : { var isUnicode = facets [ " " ] . GetValue < bool > ( false ) ; var isFixedLength = facets [ " " ] . GetValue < bool > ( false ) ; var maxLengthFacet = facets [ " " ] ; var maxLength = maxLengthFacet . GetValue < int ? > ( ) ; if ( maxLengthFacet . IsUnbounded || maxLength == null || maxLength . Value > varcharMaxSize ) { maxLength = null ; } var storeTypeName = isFixedLength ? " " : " " ; storeTypeName = isUnicode ? " " + storeTypeName : storeTypeName ; storeTypeName = ( maxLength == null ) ? " " + storeTypeName : storeTypeName ; return CreateStringTypeUsage ( StoreTypeNameToStorePrimitiveType [ storeTypeName ] , isUnicode , isFixedLength , maxLength ) ; } case PrimitiveTypeKind . DateTime : return TypeUsage . CreateDefaultTypeUsage ( StoreTypeNameToStorePrimitiveType [ " " ] ) ; case PrimitiveTypeKind . Time : return TypeUsage . CreateDefaultTypeUsage ( StoreTypeNameToStorePrimitiveType [ " " ] ) ; default : throw new NotSupportedException ( String . Format ( " " , edmType , primitiveType . PrimitiveTypeKind ) ) ; } }
This method takes a type and a set of facets and returns the best mapped equivalent type
in Ingres, taking the store version into consideration.
This method takes a type and a set of facets and returns the best mapped equivalent type in Ingres taking the store version into consideration .
// decimal, money // byte, byte varying, long byte // char, nchar, varchar, nvarchar, long varchar, long nvarchar // ingresdate // time
A TypeUsage encapsulating a store type and a set of facets
A TypeUsage encapsulating a store type and a set of facets
edmType
TypeUsage
storeType
A TypeUsage encapsulating an EDM type and a set of facets
A TypeUsage encapsulating an EDM type and a set of facets