Example #1
0
        /// <summary>
        /// Create the one and only native to backend type map.
        /// This map is used when formatting native data
        /// types to backend representations.
        /// </summary>
        private static void VerifyDefaultTypesMap()
        {
            lock (CLASSNAME) {
                if (NativeTypeMapping != null)
                {
                    return;
                }

                NativeTypeMapping = new NpgsqlNativeTypeMapping();


                // Conflicting types should have mapped first the non default mappings.
                // For example, char, varchar and text map to DbType.String. As the most
                // common is to use text with string, it has to be the last mapped, in order
                // to type mapping has the last entry, in this case, text, as the map value
                // for DbType.String.

                NativeTypeMapping.AddType("refcursor", NpgsqlDbType.Refcursor, DbType.String, true, null);

                NativeTypeMapping.AddType("char", NpgsqlDbType.Char, DbType.String, true, null);

                NativeTypeMapping.AddType("varchar", NpgsqlDbType.Varchar, DbType.String, true, null);

                NativeTypeMapping.AddType("text", NpgsqlDbType.Text, DbType.String, true, null);

                NativeTypeMapping.AddDbTypeAlias("text", DbType.StringFixedLength);
                NativeTypeMapping.AddDbTypeAlias("text", DbType.AnsiString);
                NativeTypeMapping.AddDbTypeAlias("text", DbType.AnsiStringFixedLength);
                NativeTypeMapping.AddTypeAlias("text", typeof(String));


                NativeTypeMapping.AddType("bytea", NpgsqlDbType.Bytea, DbType.Binary, true,
                                          new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToBinary));

                NativeTypeMapping.AddTypeAlias("bytea", typeof(Byte[]));

                NativeTypeMapping.AddType("bit", NpgsqlDbType.Bit, DbType.Boolean, true,
                                          new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToBit));

                NativeTypeMapping.AddType("bool", NpgsqlDbType.Boolean, DbType.Boolean, false,
                                          new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToBoolean));

                NativeTypeMapping.AddTypeAlias("bool", typeof(Boolean));

                NativeTypeMapping.AddType("int2", NpgsqlDbType.Smallint, DbType.Int16, false,
                                          null);

                NativeTypeMapping.AddTypeAlias("int2", typeof(Int16));

                NativeTypeMapping.AddDbTypeAlias("int2", DbType.Byte);

                NativeTypeMapping.AddTypeAlias("int2", typeof(Byte));

                NativeTypeMapping.AddType("int4", NpgsqlDbType.Integer, DbType.Int32, false,
                                          null);

                NativeTypeMapping.AddTypeAlias("int4", typeof(Int32));

                NativeTypeMapping.AddType("int8", NpgsqlDbType.Bigint, DbType.Int64, false,
                                          null);

                NativeTypeMapping.AddTypeAlias("int8", typeof(Int64));

                NativeTypeMapping.AddType("float4", NpgsqlDbType.Real, DbType.Single, true,
                                          null);

                NativeTypeMapping.AddTypeAlias("float4", typeof(Single));

                NativeTypeMapping.AddType("float8", NpgsqlDbType.Double, DbType.Double, true,
                                          null);

                NativeTypeMapping.AddTypeAlias("float8", typeof(Double));

                NativeTypeMapping.AddType("numeric", NpgsqlDbType.Numeric, DbType.Decimal, false,
                                          null);

                NativeTypeMapping.AddTypeAlias("numeric", typeof(Decimal));

                NativeTypeMapping.AddType("currency", NpgsqlDbType.Money, DbType.Currency, true,
                                          new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToMoney));

                NativeTypeMapping.AddType("date", NpgsqlDbType.Date, DbType.Date, true,
                                          new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToDate));

                NativeTypeMapping.AddType("time", NpgsqlDbType.Time, DbType.Time, true,
                                          new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToTime));

                NativeTypeMapping.AddType("timestamp", NpgsqlDbType.Timestamp, DbType.DateTime, true,
                                          new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToDateTime));

                NativeTypeMapping.AddTypeAlias("timestamp", typeof(DateTime));

                NativeTypeMapping.AddType("timestamptz", NpgsqlDbType.TimestampTZ, DbType.DateTime, true,
                                          new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToDateTime));

                NativeTypeMapping.AddType("point", NpgsqlDbType.Point, DbType.Object, true,
                                          new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToPoint));

                NativeTypeMapping.AddTypeAlias("point", typeof(NpgsqlPoint));

                NativeTypeMapping.AddType("box", NpgsqlDbType.Box, DbType.Object, true,
                                          new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToBox));

                NativeTypeMapping.AddTypeAlias("box", typeof(NpgsqlBox));

                NativeTypeMapping.AddType("lseg", NpgsqlDbType.LSeg, DbType.Object, true,
                                          new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToLSeg));

                NativeTypeMapping.AddTypeAlias("lseg", typeof(NpgsqlLSeg));

                NativeTypeMapping.AddType("path", NpgsqlDbType.Path, DbType.Object, true,
                                          new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToPath));

                NativeTypeMapping.AddTypeAlias("path", typeof(NpgsqlPath));

                NativeTypeMapping.AddType("polygon", NpgsqlDbType.Polygon, DbType.Object, true,
                                          new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToPolygon));

                NativeTypeMapping.AddTypeAlias("polygon", typeof(NpgsqlPolygon));

                NativeTypeMapping.AddType("circle", NpgsqlDbType.Circle, DbType.Object, true,
                                          new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToCircle));

                NativeTypeMapping.AddTypeAlias("circle", typeof(NpgsqlCircle));

                NativeTypeMapping.AddType("inet", NpgsqlDbType.Inet, DbType.Object, true,
                                          new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToIPAddress));

                NativeTypeMapping.AddTypeAlias("inet", typeof(IPAddress));
                NativeTypeMapping.AddTypeAlias("inet", typeof(NpgsqlInet));
            }
        }
Example #2
0
        /// <summary>
        /// Create the one and only native to backend type map.
        /// This map is used when formatting native data
        /// types to backend representations.
        /// </summary>
        private static void VerifyDefaultTypesMap()
        {
            lock(CLASSNAME) {
                if (NativeTypeMapping != null) {
                    return;
                }

                NativeTypeMapping = new NpgsqlNativeTypeMapping();
                
                
                // Conflicting types should have mapped first the non default mappings.
                // For example, char, varchar and text map to DbType.String. As the most 
                // common is to use text with string, it has to be the last mapped, in order
                // to type mapping has the last entry, in this case, text, as the map value
                // for DbType.String.
                
                NativeTypeMapping.AddType("refcursor", NpgsqlDbType.Refcursor, DbType.String, true, null);
                
                NativeTypeMapping.AddType("char", NpgsqlDbType.Char, DbType.String, true, null);
                
                NativeTypeMapping.AddType("varchar", NpgsqlDbType.Varchar, DbType.String, true, null);

                NativeTypeMapping.AddType("text", NpgsqlDbType.Text, DbType.String, true, null);

                NativeTypeMapping.AddDbTypeAlias("text", DbType.StringFixedLength);
                NativeTypeMapping.AddDbTypeAlias("text", DbType.AnsiString);
                NativeTypeMapping.AddDbTypeAlias("text", DbType.AnsiStringFixedLength);
                NativeTypeMapping.AddTypeAlias("text", typeof(String));

                                                
                NativeTypeMapping.AddType("bytea", NpgsqlDbType.Bytea, DbType.Binary, true,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToBinary));

                NativeTypeMapping.AddTypeAlias("bytea", typeof(Byte[]));

                NativeTypeMapping.AddType("bit", NpgsqlDbType.Bit, DbType.Boolean, true,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToBit));

                NativeTypeMapping.AddType("bool", NpgsqlDbType.Boolean, DbType.Boolean, false,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToBoolean));

                NativeTypeMapping.AddTypeAlias("bool", typeof(Boolean));
                                
                NativeTypeMapping.AddType("int2", NpgsqlDbType.Smallint, DbType.Int16, false,
                null);

                NativeTypeMapping.AddTypeAlias("int2", typeof(Int16));
                                
                NativeTypeMapping.AddDbTypeAlias("int2", DbType.Byte);
                
                NativeTypeMapping.AddTypeAlias("int2", typeof(Byte));
                
                NativeTypeMapping.AddType("int4", NpgsqlDbType.Integer, DbType.Int32, false,
                null);

                NativeTypeMapping.AddTypeAlias("int4", typeof(Int32));

                NativeTypeMapping.AddType("int8", NpgsqlDbType.Bigint, DbType.Int64, false,
                null);

                NativeTypeMapping.AddTypeAlias("int8", typeof(Int64));

                NativeTypeMapping.AddType("float4", NpgsqlDbType.Real, DbType.Single, true,
                null);

                NativeTypeMapping.AddTypeAlias("float4", typeof(Single));

                NativeTypeMapping.AddType("float8", NpgsqlDbType.Double, DbType.Double, true,
                null);

                NativeTypeMapping.AddTypeAlias("float8", typeof(Double));

                NativeTypeMapping.AddType("numeric", NpgsqlDbType.Numeric, DbType.Decimal, false,
                null);

                NativeTypeMapping.AddTypeAlias("numeric", typeof(Decimal));

                NativeTypeMapping.AddType("currency", NpgsqlDbType.Money, DbType.Currency, true,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToMoney));

                NativeTypeMapping.AddType("date", NpgsqlDbType.Date, DbType.Date, true,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToDate));

                NativeTypeMapping.AddType("time", NpgsqlDbType.Time, DbType.Time, true,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToTime));

                NativeTypeMapping.AddType("timestamp", NpgsqlDbType.Timestamp, DbType.DateTime, true,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToDateTime));

                NativeTypeMapping.AddTypeAlias("timestamp", typeof(DateTime));

                NativeTypeMapping.AddType("timestamptz", NpgsqlDbType.TimestampTZ, DbType.DateTime, true,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToDateTime));

                NativeTypeMapping.AddType("point", NpgsqlDbType.Point, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToPoint));

                NativeTypeMapping.AddTypeAlias("point", typeof(NpgsqlPoint));
                
                NativeTypeMapping.AddType("box", NpgsqlDbType.Box, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToBox));

                NativeTypeMapping.AddTypeAlias("box", typeof(NpgsqlBox));
                
                NativeTypeMapping.AddType("lseg", NpgsqlDbType.LSeg, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToLSeg));

                NativeTypeMapping.AddTypeAlias("lseg", typeof(NpgsqlLSeg));

                NativeTypeMapping.AddType("path", NpgsqlDbType.Path, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToPath));

                NativeTypeMapping.AddTypeAlias("path", typeof(NpgsqlPath));

                NativeTypeMapping.AddType("polygon", NpgsqlDbType.Polygon, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToPolygon));

                NativeTypeMapping.AddTypeAlias("polygon", typeof(NpgsqlPolygon));

                NativeTypeMapping.AddType("circle", NpgsqlDbType.Circle, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToCircle));

                NativeTypeMapping.AddTypeAlias("circle", typeof(NpgsqlCircle));

                NativeTypeMapping.AddType("inet", NpgsqlDbType.Inet, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToIPAddress));

                NativeTypeMapping.AddTypeAlias("inet", typeof(IPAddress));
                NativeTypeMapping.AddTypeAlias("inet", typeof(NpgsqlInet));
            }
        }
Example #3
0
        /// <summary>
        /// Create the one and only native to backend type map.
        /// This map is used when formatting native data
        /// types to backend representations.
        /// </summary>
        private static NpgsqlNativeTypeMapping PrepareDefaultTypesMap()
        {
            NpgsqlNativeTypeMapping nativeTypeMapping = new NpgsqlNativeTypeMapping();

            nativeTypeMapping.AddType("name", NpgsqlDbType.Name, DbType.String, true, null);

            nativeTypeMapping.AddType("oidvector", NpgsqlDbType.Oidvector, DbType.String, true, null);

            // Conflicting types should have mapped first the non default mappings.
            // For example, char, varchar and text map to DbType.String. As the most
            // common is to use text with string, it has to be the last mapped, in order
            // to type mapping has the last entry, in this case, text, as the map value
            // for DbType.String.

            nativeTypeMapping.AddType("refcursor", NpgsqlDbType.Refcursor, DbType.String, true, null);

            nativeTypeMapping.AddType("char", NpgsqlDbType.Char, DbType.String, false,
                                      BasicNativeToBackendTypeConverter.StringToTextText,
                                      BasicNativeToBackendTypeConverter.StringToTextBinary);

            nativeTypeMapping.AddTypeAlias("char", typeof(Char));

            nativeTypeMapping.AddType("varchar", NpgsqlDbType.Varchar, DbType.String, false,
                                      BasicNativeToBackendTypeConverter.StringToTextText,
                                      BasicNativeToBackendTypeConverter.StringToTextBinary);

            // Dummy type that facilitates non-binary string conversions for types that are treated as
            // text but which are not really text.  Those types cause problems if they are encoded as binary.
            // The mapping NpgsqlDbType.Text => text_nonbinary is removed when text is mapped.
            // DBType.Object will be re-mapped to this type at the end.
            nativeTypeMapping.AddType("text_nonbinary", NpgsqlDbType.Text, DbType.Object, true);

            nativeTypeMapping.AddType("text", NpgsqlDbType.Text, DbType.String, false,
                                      BasicNativeToBackendTypeConverter.StringToTextText,
                                      BasicNativeToBackendTypeConverter.StringToTextBinary);

            nativeTypeMapping.AddDbTypeAlias("text", DbType.StringFixedLength);
            nativeTypeMapping.AddDbTypeAlias("text", DbType.AnsiString);
            nativeTypeMapping.AddDbTypeAlias("text", DbType.AnsiStringFixedLength);

            nativeTypeMapping.AddTypeAlias("text", typeof(String));

            nativeTypeMapping.AddType("bytea", NpgsqlDbType.Bytea, DbType.Binary, false,
                                      BasicNativeToBackendTypeConverter.ByteArrayToByteaText,
                                      BasicNativeToBackendTypeConverter.ByteArrayToByteaBinary);

            nativeTypeMapping.AddTypeAlias("bytea", typeof(Byte[]));

            nativeTypeMapping.AddType("bit", NpgsqlDbType.Bit, DbType.Object, false,
                                      BasicNativeToBackendTypeConverter.ToBit);

            nativeTypeMapping.AddTypeAlias("bit", typeof(BitString));

            nativeTypeMapping.AddType("bool", NpgsqlDbType.Boolean, DbType.Boolean, false,
                                      BasicNativeToBackendTypeConverter.BooleanToBooleanText,
                                      BasicNativeToBackendTypeConverter.BooleanToBooleanBinary);

            nativeTypeMapping.AddTypeAlias("bool", typeof(Boolean));

            nativeTypeMapping.AddType("int2", NpgsqlDbType.Smallint, DbType.Int16, false,
                                      BasicNativeToBackendTypeConverter.ToBasicType <short>,
                                      BasicNativeToBackendTypeConverter.Int16ToInt2Binary);

            nativeTypeMapping.AddTypeAlias("int2", typeof(UInt16));

            nativeTypeMapping.AddTypeAlias("int2", typeof(Int16));

            nativeTypeMapping.AddDbTypeAlias("int2", DbType.Byte);

            nativeTypeMapping.AddTypeAlias("int2", typeof(Byte));

            nativeTypeMapping.AddType("int4", NpgsqlDbType.Integer, DbType.Int32, false,
                                      BasicNativeToBackendTypeConverter.ToBasicType <int>,
                                      BasicNativeToBackendTypeConverter.Int32ToInt4Binary);

            nativeTypeMapping.AddTypeAlias("int4", typeof(Int32));

            nativeTypeMapping.AddType("int8", NpgsqlDbType.Bigint, DbType.Int64, false,
                                      BasicNativeToBackendTypeConverter.ToBasicType <long>,
                                      BasicNativeToBackendTypeConverter.Int64ToInt8Binary);

            nativeTypeMapping.AddTypeAlias("int8", typeof(Int64));

            nativeTypeMapping.AddType("float4", NpgsqlDbType.Real, DbType.Single, false,
                                      BasicNativeToBackendTypeConverter.SingleDoubleToFloat4Float8Text,
                                      BasicNativeToBackendTypeConverter.SingleToFloat4Binary);

            nativeTypeMapping.AddTypeAlias("float4", typeof(Single));

            nativeTypeMapping.AddType("float8", NpgsqlDbType.Double, DbType.Double, false,
                                      BasicNativeToBackendTypeConverter.SingleDoubleToFloat4Float8Text,
                                      BasicNativeToBackendTypeConverter.DoubleToFloat8Binary);

            nativeTypeMapping.AddTypeAlias("float8", typeof(Double));

            nativeTypeMapping.AddType("numeric", NpgsqlDbType.Numeric, DbType.Decimal, false,
                                      BasicNativeToBackendTypeConverter.ToBasicType <decimal>);

            nativeTypeMapping.AddTypeAlias("numeric", typeof(Decimal));

            nativeTypeMapping.AddType("money", NpgsqlDbType.Money, DbType.Currency, true,
                                      BasicNativeToBackendTypeConverter.ToMoney);

            nativeTypeMapping.AddType("date", NpgsqlDbType.Date, DbType.Date, true,
                                      BasicNativeToBackendTypeConverter.ToDate);

            nativeTypeMapping.AddTypeAlias("date", typeof(NpgsqlDate));

            nativeTypeMapping.AddType("timetz", NpgsqlDbType.TimeTZ, DbType.Time, true,
                                      ExtendedNativeToBackendTypeConverter.ToTimeTZ);

            nativeTypeMapping.AddTypeAlias("timetz", typeof(NpgsqlTimeTZ));

            nativeTypeMapping.AddType("time", NpgsqlDbType.Time, DbType.Time, true,
                                      BasicNativeToBackendTypeConverter.ToTime);

            nativeTypeMapping.AddTypeAlias("time", typeof(NpgsqlTime));

            nativeTypeMapping.AddType("timestamptz", NpgsqlDbType.TimestampTZ, DbType.DateTime, true,
                                      ExtendedNativeToBackendTypeConverter.ToTimeStamp);

            nativeTypeMapping.AddTypeAlias("timestamptz", typeof(NpgsqlTimeStampTZ));

            nativeTypeMapping.AddDbTypeAlias("timestamptz", DbType.DateTimeOffset);

            nativeTypeMapping.AddTypeAlias("timestamptz", typeof(DateTimeOffset));

            nativeTypeMapping.AddType("abstime", NpgsqlDbType.Abstime, DbType.DateTime, true,
                                      ExtendedNativeToBackendTypeConverter.ToTimeStamp);

            nativeTypeMapping.AddType("timestamp", NpgsqlDbType.Timestamp, DbType.DateTime, true,
                                      ExtendedNativeToBackendTypeConverter.ToTimeStamp);

            nativeTypeMapping.AddTypeAlias("timestamp", typeof(DateTime));
            nativeTypeMapping.AddTypeAlias("timestamp", typeof(NpgsqlTimeStamp));

            nativeTypeMapping.AddType("point", NpgsqlDbType.Point, DbType.Object, true,
                                      ExtendedNativeToBackendTypeConverter.ToPoint);

            nativeTypeMapping.AddTypeAlias("point", typeof(NpgsqlPoint));

            nativeTypeMapping.AddType("box", NpgsqlDbType.Box, DbType.Object, true,
                                      ExtendedNativeToBackendTypeConverter.ToBox);

            nativeTypeMapping.AddTypeAlias("box", typeof(NpgsqlBox));

            nativeTypeMapping.AddType("lseg", NpgsqlDbType.LSeg, DbType.Object, true,
                                      ExtendedNativeToBackendTypeConverter.ToLSeg);

            nativeTypeMapping.AddTypeAlias("lseg", typeof(NpgsqlLSeg));

            nativeTypeMapping.AddType("path", NpgsqlDbType.Path, DbType.Object, true,
                                      ExtendedNativeToBackendTypeConverter.ToPath);

            nativeTypeMapping.AddTypeAlias("path", typeof(NpgsqlPath));

            nativeTypeMapping.AddType("polygon", NpgsqlDbType.Polygon, DbType.Object, true,
                                      ExtendedNativeToBackendTypeConverter.ToPolygon);

            nativeTypeMapping.AddTypeAlias("polygon", typeof(NpgsqlPolygon));

            nativeTypeMapping.AddType("circle", NpgsqlDbType.Circle, DbType.Object, true,
                                      ExtendedNativeToBackendTypeConverter.ToCircle);

            nativeTypeMapping.AddTypeAlias("circle", typeof(NpgsqlCircle));

            nativeTypeMapping.AddType("inet", NpgsqlDbType.Inet, DbType.Object, true,
                                      ExtendedNativeToBackendTypeConverter.ToIPAddress);

            nativeTypeMapping.AddTypeAlias("inet", typeof(IPAddress));
            nativeTypeMapping.AddTypeAlias("inet", typeof(NpgsqlInet));

            nativeTypeMapping.AddType("macaddr", NpgsqlDbType.MacAddr, DbType.Object, true,
                                      ExtendedNativeToBackendTypeConverter.ToMacAddress);

            nativeTypeMapping.AddTypeAlias("macaddr", typeof(PhysicalAddress));
            nativeTypeMapping.AddTypeAlias("macaddr", typeof(NpgsqlMacAddress));

            nativeTypeMapping.AddType("uuid", NpgsqlDbType.Uuid, DbType.Guid, true);
            nativeTypeMapping.AddTypeAlias("uuid", typeof(Guid));

            nativeTypeMapping.AddType("xml", NpgsqlDbType.Xml, DbType.Xml, true);

            nativeTypeMapping.AddType("interval", NpgsqlDbType.Interval, DbType.Object, true,
                                      ExtendedNativeToBackendTypeConverter.ToInterval);

            nativeTypeMapping.AddTypeAlias("interval", typeof(NpgsqlInterval));
            nativeTypeMapping.AddTypeAlias("interval", typeof(TimeSpan));

            nativeTypeMapping.AddDbTypeAlias("text_nonbinary", DbType.Object);

            return(nativeTypeMapping);
        }
        /// <summary>
        /// Create the one and only native to backend type map.
        /// This map is used when formatting native data
        /// types to backend representations.
        /// </summary>
        private static void VerifyDefaultTypesMap()
        {
            lock(CLASSNAME) {
                if (NativeTypeMapping != null) {
                    return;
                }

                NativeTypeMapping = new NpgsqlNativeTypeMapping();

                NativeTypeMapping.AddType("text", NpgsqlDbType.Text, DbType.String, true, null);

                NativeTypeMapping.AddDbTypeAlias("text", DbType.StringFixedLength);
                NativeTypeMapping.AddDbTypeAlias("text", DbType.AnsiString);
                NativeTypeMapping.AddDbTypeAlias("text", DbType.AnsiStringFixedLength);
                NativeTypeMapping.AddTypeAlias("text", typeof(String));

		NativeTypeMapping.AddType("varchar", NpgsqlDbType.Varchar, DbType.String, true, null);

                NativeTypeMapping.AddType("bytea", NpgsqlDbType.Bytea, DbType.Binary, true,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToBinary));

                NativeTypeMapping.AddTypeAlias("bytea", typeof(Byte[]));

                NativeTypeMapping.AddType("bool", NpgsqlDbType.Boolean, DbType.Boolean, false,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToBoolean));

                NativeTypeMapping.AddTypeAlias("bool", typeof(Boolean));
                                
                NativeTypeMapping.AddType("int2", NpgsqlDbType.Smallint, DbType.Int16, false,
                null);

                NativeTypeMapping.AddTypeAlias("int2", typeof(Int16));
                
                NativeTypeMapping.AddDbTypeAlias("int2", DbType.Byte);

                NativeTypeMapping.AddType("int4", NpgsqlDbType.Integer, DbType.Int32, false,
                null);

                NativeTypeMapping.AddTypeAlias("int4", typeof(Int32));

                NativeTypeMapping.AddType("int8", NpgsqlDbType.Bigint, DbType.Int64, false,
                null);

                NativeTypeMapping.AddTypeAlias("int8", typeof(Int64));

                NativeTypeMapping.AddType("float4", NpgsqlDbType.Real, DbType.Single, false,
                null);

                NativeTypeMapping.AddTypeAlias("float4", typeof(Single));

                NativeTypeMapping.AddType("float8", NpgsqlDbType.Double, DbType.Double, false,
                null);

                NativeTypeMapping.AddTypeAlias("float8", typeof(Double));

                NativeTypeMapping.AddType("numeric", NpgsqlDbType.Numeric, DbType.Decimal, false,
                null);

                NativeTypeMapping.AddTypeAlias("numeric", typeof(Decimal));

                NativeTypeMapping.AddType("currency", NpgsqlDbType.Money, DbType.Currency, true,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToMoney));

                NativeTypeMapping.AddType("date", NpgsqlDbType.Date, DbType.Date, true,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToDate));

                NativeTypeMapping.AddType("time", NpgsqlDbType.Time, DbType.Time, true,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToTime));

                NativeTypeMapping.AddType("timestamp", NpgsqlDbType.Timestamp, DbType.DateTime, true,
                new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToDateTime));

                NativeTypeMapping.AddTypeAlias("timestamp", typeof(DateTime));

                NativeTypeMapping.AddType("point", NpgsqlDbType.Point, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToPoint));

                NativeTypeMapping.AddTypeAlias("point", typeof(NpgsqlPoint));
                
                NativeTypeMapping.AddType("box", NpgsqlDbType.Box, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToBox));

                NativeTypeMapping.AddTypeAlias("box", typeof(NpgsqlBox));
                
                NativeTypeMapping.AddType("lseg", NpgsqlDbType.LSeg, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToLSeg));

                NativeTypeMapping.AddTypeAlias("lseg", typeof(NpgsqlLSeg));

                NativeTypeMapping.AddType("path", NpgsqlDbType.Path, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToPath));

                NativeTypeMapping.AddTypeAlias("path", typeof(NpgsqlPath));

                NativeTypeMapping.AddType("polygon", NpgsqlDbType.Polygon, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToPolygon));

                NativeTypeMapping.AddTypeAlias("polygon", typeof(NpgsqlPolygon));

                NativeTypeMapping.AddType("circle", NpgsqlDbType.Circle, DbType.Object, true,
                new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToCircle));

                NativeTypeMapping.AddTypeAlias("circle", typeof(NpgsqlCircle));
            }
        }