当前位置: 首页>>代码示例>>C#>>正文


C# NpgsqlDataAdapter.?.Dispose方法代码示例

本文整理汇总了C#中Npgsql.NpgsqlDataAdapter.?.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# NpgsqlDataAdapter.?.Dispose方法的具体用法?C# NpgsqlDataAdapter.?.Dispose怎么用?C# NpgsqlDataAdapter.?.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Npgsql.NpgsqlDataAdapter的用法示例。


在下文中一共展示了NpgsqlDataAdapter.?.Dispose方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessDimRows

        /// <summary>
        ///     Procces the bytea or array columns.
        /// </summary>
        /// <param name="dr"></param>
        private static void ProcessDimRows(DataRow[] dr)
        {
            var sql = BuildCommand(dr);

            var dt = new DataTable();
            NpgsqlDataAdapter da = null;

            try
            {
                da = new NpgsqlDataAdapter(sql, _pgConn);
                da.Fill(dt);

                if (dt.Rows.Count == 0) return;

                var dimRow = dt.Rows[0];

                foreach (var row in dr)
                {
                    var rowName = row["column_name"] + DimPostfix;
                    if (row["regtype"].ToString() != "bytea")
                        row["dim_size"] = dimRow[rowName];
                    else row["max_char_size"] = dimRow[rowName];
                }
            }
            catch (NpgsqlException ex) {
                _log.WriteEx('E', Constants.LogTsType, ex);
            }
            finally
            {
                dt.Dispose();
                da?.Dispose();
            }
        }
开发者ID:mvrolijk,项目名称:ConvertPG2SS,代码行数:37,代码来源:PostgresSchemaTables.cs

示例2: CreateTypeTable

        /// <summary>
        /// 
        /// </summary>
        private static void CreateTypeTable()
        {
            #region PostgreSQL query to retrieve type/domain information from pg_catalog.

            const string sql =
                @"SELECT n.nspname as schema_name, format_type(t.oid, NULL) AS type_name,
                (typbasetype::regtype)::text AS regtype, typnotnull AS notnull,
                format_type(typbasetype, typtypmod) AS data_type, typndims AS dims,
                    CASE
                        WHEN typbasetype = ANY (ARRAY[1042::oid, 1043::oid, 1015::oid]) THEN
                        CASE
                            WHEN typtypmod > 0 THEN typtypmod - 4
                            ELSE -1
                        END
                    END AS max_char_size,
                    CASE typbasetype
                        WHEN 21 THEN 16
                        WHEN 23 THEN 32
                        WHEN 20 THEN 64
                        WHEN 1700 THEN
                        CASE
                            WHEN typtypmod = (-1) THEN NULL::integer
                            ELSE ((typtypmod - 4) >> 16) & 65535
                        END
                        WHEN 700 THEN 24
                        WHEN 701 THEN 53
                        ELSE NULL::integer
                    END AS numeric_precision,
                    CASE
                        WHEN typbasetype = ANY (ARRAY[21::oid, 23::oid, 20::oid]) THEN 0
                        WHEN typbasetype = 1700::oid THEN
                            CASE
                                WHEN typtypmod = (-1) THEN NULL::integer
                                ELSE (typtypmod - 4) & 65535
                            END
                        ELSE NULL::integer
                    END AS numeric_scale,
                    typdefault as default_val, typisdefined, typdelim,
                    obj_description(t.oid, 'pg_type') as comment
                FROM pg_type t
                     LEFT JOIN pg_namespace n ON n.oid = t.typnamespace
                WHERE (t.typrelid = 0 OR
                       (SELECT c.relkind = 'c' FROM pg_class c WHERE c.oid = t.typrelid))
                      AND NOT EXISTS(SELECT 1 FROM pg_type el WHERE el.oid = t.typelem
                                     AND el.typarray = t.oid)
                      AND pg_type_is_visible(t.oid)
                      AND nspname <> 'pg_catalog' AND typbasetype <> 0 ORDER BY 1, 2";

            #endregion

            var tblDict = ((Dictionary<string, DataTable>) _params[Constants.PgTables]);
            var dt = tblDict[Constants.PgTypeTable];

            NpgsqlDataAdapter da = null;

            try
            {
                da = new NpgsqlDataAdapter(sql, _pgConn);
                da.Fill(dt);
            }
            catch (NpgsqlException ex) {
                _log.WriteEx('E', Constants.LogTsType, ex);
            }
            finally { da?.Dispose(); }

            if (dt.Rows.Count == 0) return;

            // Add primary key to table.
            var columns = new DataColumn[2];
            columns[0] = dt.Columns["schema_name"];
            columns[1] = dt.Columns["type_name"];
            dt.PrimaryKey = columns;
        }
开发者ID:mvrolijk,项目名称:ConvertPG2SS,代码行数:76,代码来源:PostgresSchemaTables.cs

示例3: CreateSequenceTable

        /// <summary>
        /// 
        /// </summary>
        private static void CreateSequenceTable(string inList)
        {
            var sql =
                string.Format(
                    CultureInfo.InvariantCulture,
                    @"SELECT n.nspname AS schema_name, c.relname AS seq_name
                    FROM	pg_class c
                        JOIN pg_namespace n ON c.relnamespace = n.oid
                    WHERE	c.relkind = 'S' AND n.nspname NOT IN({0})
                    ORDER	BY n.nspname ASC, c.relname ASC",
                    inList);

            var tblDict = ((Dictionary<string, DataTable>) _params[Constants.PgTables]);
            var dt = tblDict[Constants.PgSeqTable];

            NpgsqlDataAdapter da = null;

            try
            {
                da = new NpgsqlDataAdapter(sql, _pgConn);
                da.Fill(dt);
            }
            catch (NpgsqlException ex) {
                _log.WriteEx('E', Constants.LogTsType, ex);
            }
            finally { da?.Dispose(); }

            if (dt.Rows.Count == 0) return;

            // Add sequence specification columns.
            dt.Columns.Add("regtype", typeof (string));
            dt.Columns.Add("last_value", typeof (long));
            dt.Columns.Add("start_value", typeof (long));
            dt.Columns.Add("increment_by", typeof (long));
            dt.Columns.Add("max_value", typeof (long));
            dt.Columns.Add("min_value", typeof (long));
            dt.Columns.Add("cache_value", typeof (long));
            dt.Columns.Add("log_cnt", typeof (long));
            dt.Columns.Add("is_cycled", typeof (bool));
            dt.Columns.Add("is_called", typeof (bool));

            // Add primary key to table.
            var columns = new DataColumn[2];
            columns[0] = dt.Columns["schema_name"];
            columns[1] = dt.Columns["seq_name"];
            dt.PrimaryKey = columns;

            ReadSequenceDetails(dt);
        }
开发者ID:mvrolijk,项目名称:ConvertPG2SS,代码行数:52,代码来源:PostgresSchemaTables.cs

示例4: CreateSchemaTable

        /// <summary>
        /// 
        /// </summary>
        private static void CreateSchemaTable(string inList)
        {
            #region PostgreSQL query to retrieve coloumn information from pg_catalog.
            var sql =
                string.Format(
                    CultureInfo.InvariantCulture,
                    @"SELECT n.nspname AS schema_name, c.relname AS table_name,
                    a.attname AS column_name, a.attnum AS column_index,
                    (a.atttypid::regtype)::text AS regtype, a.attnotnull AS notnull,
                    format_type(a.atttypid, a.atttypmod) AS data_type, a.attndims AS dims,
                    CASE
                        WHEN a.atttypid = ANY (ARRAY[1042::oid, 1043::oid, 1015::oid]) THEN
                            CASE
                                WHEN a.atttypmod > 0 THEN a.atttypmod - 4
                                ELSE -1
                            END
                    END AS max_char_size,
                    CASE a.atttypid
                        WHEN 21 THEN 16
                        WHEN 23 THEN 32
                        WHEN 20 THEN 64
                        WHEN 1700 THEN
                        CASE
                            WHEN a.atttypmod = (-1) THEN NULL::integer
                            ELSE ((a.atttypmod - 4) >> 16) & 65535
                        END
                        WHEN 700 THEN 24
                        WHEN 701 THEN 53
                        ELSE NULL::integer
                    END AS numeric_precision,
                    CASE
                        WHEN a.atttypid = ANY (ARRAY[21::oid, 23::oid, 20::oid]) THEN 0
                        WHEN a.atttypid = 1700::oid THEN
                            CASE
                                WHEN a.atttypmod = (-1) THEN NULL::integer
                                ELSE (a.atttypmod - 4) & 65535
                            END
                        ELSE NULL::integer
                    END AS numeric_scale,
                    d.adsrc AS default_val,
                    (SELECT col_description(a.attrelid, a.attnum::integer) AS col_description)
                        AS comment
                    FROM pg_class c
                        LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
                        LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
                        LEFT JOIN pg_attribute a ON a.attrelid = c.oid AND a.attnum > 0
                        LEFT JOIN pg_attrdef d ON d.adrelid = a.attrelid AND d.adnum = a.attnum
                    WHERE c.relkind = 'r'::""char"" AND (a.atttypid::regtype)::text <> '-'
                          AND n.nspname NOT IN({0})
                    ORDER BY n.nspname ASC, c.relname ASC, a.attnum ASC",
                    inList);

            #endregion

            var tblDict = ((Dictionary<string, DataTable>) _params[Constants.PgTables]);
            var dt = tblDict[Constants.PgSchemaTable];

            NpgsqlDataAdapter da = null;

            try
            {
                da = new NpgsqlDataAdapter(sql, _pgConn);
                da.Fill(dt);
            }
            catch (NpgsqlException ex) {
                _log.WriteEx('E', Constants.LogTsType, ex);
            }
            finally { da?.Dispose(); }

            if (dt.Rows.Count == 0) return;

            // Add a dim size coloumn.
            dt.Columns.Add("dim_size", typeof (int));

            // Add primary key to table.
            var columns = new DataColumn[3];
            columns[0] = dt.Columns["schema_name"];
            columns[1] = dt.Columns["table_name"];
            columns[2] = dt.Columns["column_name"];
            dt.PrimaryKey = columns;

            ProcessDimensions(dt);
        }
开发者ID:mvrolijk,项目名称:ConvertPG2SS,代码行数:86,代码来源:PostgresSchemaTables.cs

示例5: CreateFkTable


//.........这里部分代码省略.........
            var where = "";
            if (!inclPublic) where = " AND ts.nspname <> 'public' ";

            #region PostgreSQL query to retrieve foreign keys information from pg_catalog.

            var sql =
                string.Format(
                    CultureInfo.InvariantCulture,
                @"SELECT pg_constraint.conname fk_name,
                         ts.nspname schema_name, tt.relname table_name,
                         os.nspname fk_schema, ot.relname fk_table,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[01]) key01,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[02]) key02,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[03]) key03,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[04]) key04,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[05]) key05,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[06]) key06,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[07]) key07,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[08]) key08,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[09]) key09,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[10]) key10,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[11]) key11,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[12]) key12,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[13]) key13,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[14]) key14,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[15]) key15,
                (select attname from pg_attribute where attrelid = pg_constraint.conrelid
                    and attnum = pg_constraint.conkey[16]) key16,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[01]) fkey01,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[02]) fkey02,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[03]) fkey03,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[04]) fkey04,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[05]) fkey05,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[06]) fkey06,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[07]) fkey07,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[08]) fkey08,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[09]) fkey09,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[10]) fkey10,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[11]) fkey11,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[12]) fkey12,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[13]) fkey13,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[14]) fkey14,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[15]) fkey15,
                (select attname from pg_attribute where attrelid = pg_constraint.confrelid
                    and attnum = pg_constraint.confkey[16]) fkey16
            FROM	pg_constraint
                JOIN pg_class as tt ON tt.oid = pg_constraint.conrelid
                    JOIN pg_namespace as ts ON tt.relnamespace = ts.oid
                JOIN pg_class as ot ON ot.oid = pg_constraint.confrelid
                    JOIN pg_namespace as os ON ot.relnamespace = os.oid
            WHERE	pg_constraint.contype = 'f' {0} ORDER BY 1",
                where);

            #endregion

            var tblDict = ((Dictionary<string, DataTable>) _params[Constants.PgTables]);
            var dt = tblDict[Constants.PgFkTable];

            NpgsqlDataAdapter da = null;

            try
            {
                da = new NpgsqlDataAdapter(sql, _pgConn);
                da.Fill(dt);
            }
            catch (NpgsqlException ex) {
                _log.WriteEx('E', Constants.LogTsType, ex);
            }
            finally { da?.Dispose(); }
        }
开发者ID:mvrolijk,项目名称:ConvertPG2SS,代码行数:101,代码来源:PostgresSchemaTables.cs

示例6: CreateCheckTable

        /// <summary>
        /// 
        /// </summary>
        private static void CreateCheckTable(string inList)
        {
            var sql =
                string.Format(
                    CultureInfo.InvariantCulture,
                    @"SELECT n.nspname AS schema_name, c.relname AS table_name,
                    a.attname AS column_name, (a.atttypid::regtype)::text AS regtype,
                    a.attnum AS column_index, o.consrc AS check_source
                    FROM pg_class c
                        JOIN pg_namespace n ON n.oid = c.relnamespace
                        JOIN pg_attribute a ON a.attrelid = c.oid AND a.attnum > 0
                        JOIN pg_constraint o ON o.conrelid = c.oid AND o.contype = 'c'::""char""
                             AND a.attnum = o.conkey[1]
                    WHERE c.relkind = 'r'::""char"" AND n.nspname NOT IN({0})
                    ORDER BY n.nspname ASC, c.relname ASC, a.attnum ASC; ",
                    inList);

            var tblDict = ((Dictionary<string, DataTable>)_params[Constants.PgTables]);
            var dt = tblDict[Constants.PgCheckTable];

            NpgsqlDataAdapter da = null;

            try
            {
                da = new NpgsqlDataAdapter(sql, _pgConn);
                da.Fill(dt);
            }
            catch (NpgsqlException ex)
            {
                _log.WriteEx('E', Constants.LogTsType, ex);
            }
            finally { da?.Dispose(); }
        }
开发者ID:mvrolijk,项目名称:ConvertPG2SS,代码行数:36,代码来源:PostgresSchemaTables.cs


注:本文中的Npgsql.NpgsqlDataAdapter.?.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。