Exemple #1
0
 public void SetUp()
 {
     var tables = new[]
         {
             new NpgTableInfo
                 {
                     Name = "Table",
                     Columns = new[]
                         {
                             new NpgColumnInfo
                                 {
                                     Name = "serial",
                                     DataType = NpgDataType.Serial
                                 },
                             new NpgColumnInfo
                                 {
                                     Name = "id",
                                     DataType = NpgDataType.Float8
                                 }
                         }
                 },
             new NpgTableInfo
                 {
                     Name = "Table2",
                     Columns = new[]
                         {
                             new NpgColumnInfo
                                 {
                                     Name = "id",
                                     DataType = NpgDataType.Int4
                                 },
                             new NpgColumnInfo
                                 {
                                     Name = "bigserial",
                                     DataType = NpgDataType.Bigserial
                                 }
                         }
                 }
         };
     _helper = SerialHelper.Create(tables);
 }
Exemple #2
0
 public static SerialHelper Create(NpgTableInfo[] tableInfos)
 {
     var helper = new SerialHelper();
     foreach (var tableInfo in tableInfos)
     {
         foreach (var columnInfo in tableInfo.Columns)
         {
             if (columnInfo.DataType == NpgDataType.Serial
                 || columnInfo.DataType == NpgDataType.Bigserial)
             {
                 if (!helper.Items.ContainsKey(tableInfo.Name))
                     helper.Items.Add(tableInfo.Name, new Dictionary<string, SerialHelperItem>());
                 helper.Items[tableInfo.Name].Add(columnInfo.Name, new SerialHelperItem
                     {
                         Table = tableInfo.Name,
                         Column = columnInfo.Name
                     });
             }
         }
     }
     return helper;
 }