示例#1
0
 IDataProvider IDataProviderFactory.GetDataProvider(IEnumerable <NamedValue> attributes)
 {
     return(PostgreSQLTools.GetDataProvider());
 }
        protected override List <DataTypeInfo> GetDataTypes(DataConnection dataConnection)
        {
            var list = new[]
            {
                new DataTypeInfo {
                    TypeName = "name", DataType = typeof(string).FullName
                },
                new DataTypeInfo {
                    TypeName = "oid", DataType = typeof(int).FullName
                },
                new DataTypeInfo {
                    TypeName = "xid", DataType = typeof(int).FullName
                },
                new DataTypeInfo {
                    TypeName = "smallint", DataType = typeof(short).FullName
                },
                new DataTypeInfo {
                    TypeName = "integer", DataType = typeof(int).FullName
                },
                new DataTypeInfo {
                    TypeName = "bigint", DataType = typeof(long).FullName
                },
                new DataTypeInfo {
                    TypeName = "real", DataType = typeof(float).FullName
                },
                new DataTypeInfo {
                    TypeName = "double precision", DataType = typeof(double).FullName
                },
                new DataTypeInfo {
                    TypeName = "boolean", DataType = typeof(bool).FullName
                },
                new DataTypeInfo {
                    TypeName = "regproc", DataType = typeof(object).FullName
                },
                new DataTypeInfo {
                    TypeName = "money", DataType = typeof(decimal).FullName
                },
                new DataTypeInfo {
                    TypeName = "text", DataType = typeof(string).FullName
                },
                new DataTypeInfo {
                    TypeName = "xml", DataType = typeof(string).FullName
                },
                new DataTypeInfo {
                    TypeName = "date", DataType = typeof(DateTime).FullName
                },
                new DataTypeInfo {
                    TypeName = "bytea", DataType = typeof(byte[]).FullName
                },
                new DataTypeInfo {
                    TypeName = "uuid", DataType = typeof(Guid).FullName
                },

                new DataTypeInfo {
                    TypeName = "hstore", DataType = typeof(Dictionary <string, string>).FullName
                },

                new DataTypeInfo {
                    TypeName = "character varying", DataType = typeof(string).FullName, CreateFormat = "character varying({0})", CreateParameters = "length"
                },
                new DataTypeInfo {
                    TypeName = "character", DataType = typeof(string).FullName, CreateFormat = "character({0})", CreateParameters = "length"
                },
                new DataTypeInfo {
                    TypeName = "numeric", DataType = typeof(decimal).FullName, CreateFormat = "numeric({0},{1})", CreateParameters = "precision,scale"
                },
                new DataTypeInfo {
                    TypeName = "timestamp with time zone", DataType = typeof(DateTimeOffset).FullName, CreateFormat = "timestamp ({0}) with time zone", CreateParameters = "precision"
                },
                new DataTypeInfo {
                    TypeName = "timestamp without time zone", DataType = typeof(DateTime).FullName, CreateFormat = "timestamp ({0}) without time zone", CreateParameters = "precision"
                },
            }.ToList();

            if (PostgreSQLTools.GetNpgsqlInetType() != null)
            {
                list.Add(new DataTypeInfo {
                    TypeName = "inet", DataType = PostgreSQLTools.GetNpgsqlInetType().FullName
                });
            }
            if (PostgreSQLTools.GetNpgsqlPointType() != null)
            {
                list.Add(new DataTypeInfo {
                    TypeName = "point", DataType = PostgreSQLTools.GetNpgsqlPointType().FullName
                });
            }
            if (PostgreSQLTools.GetNpgsqlLSegType() != null)
            {
                list.Add(new DataTypeInfo {
                    TypeName = "lseg", DataType = PostgreSQLTools.GetNpgsqlLSegType().FullName
                });
            }
            if (PostgreSQLTools.GetNpgsqlBoxType() != null)
            {
                list.Add(new DataTypeInfo {
                    TypeName = "box", DataType = PostgreSQLTools.GetNpgsqlBoxType().FullName
                });
            }
            if (PostgreSQLTools.GetNpgsqlPathType() != null)
            {
                list.Add(new DataTypeInfo {
                    TypeName = "path", DataType = PostgreSQLTools.GetNpgsqlPathType().FullName
                });
            }
            if (PostgreSQLTools.GetNpgsqlPolygonType() != null)
            {
                list.Add(new DataTypeInfo {
                    TypeName = "polygon", DataType = PostgreSQLTools.GetNpgsqlPolygonType().FullName
                });
            }
            if (PostgreSQLTools.GetNpgsqlCircleType() != null)
            {
                list.Add(new DataTypeInfo {
                    TypeName = "circle", DataType = PostgreSQLTools.GetNpgsqlCircleType().FullName
                });
            }
            if (PostgreSQLTools.GetNpgsqlIntervalType() != null)
            {
                list.Add(new DataTypeInfo {
                    TypeName = "interval", DataType = PostgreSQLTools.GetNpgsqlIntervalType().FullName, CreateFormat = "interval({0})", CreateParameters = "precision"
                });
            }
            if (PostgreSQLTools.GetNpgsqlTimeType() != null)
            {
                list.Add(new DataTypeInfo {
                    TypeName = "time with time zone", DataType = PostgreSQLTools.GetNpgsqlTimeType().FullName, CreateFormat = "time with time zone({0})", CreateParameters = "precision"
                });
            }
            if (PostgreSQLTools.GetNpgsqlTimeTZType() != null)
            {
                list.Add(new DataTypeInfo {
                    TypeName = "time without time zone", DataType = PostgreSQLTools.GetNpgsqlTimeTZType().FullName, CreateFormat = "time without time zone({0})", CreateParameters = "precision"
                });
            }

            list.Add(new DataTypeInfo {
                TypeName = "macaddr", DataType = (PostgreSQLTools.GetNpgsqlMacAddressType() ?? typeof(PhysicalAddress)).FullName
            });
            list.Add(new DataTypeInfo {
                TypeName = "bit", DataType = (PostgreSQLTools.GetBitStringType() ?? typeof(BitArray)).FullName, CreateFormat = "bit({0})", CreateParameters = "size"
            });

            return(list);
        }