예제 #1
0
        public IEnumerable<ColumInfo> GetColums(FbConnection con)
        {
            using (var command = con.CreateCommand())
            {
                command.CommandText =
                    $"select trim(rf.rdb$field_name) Name, f.rdb$field_type Type, f.rdb$field_sub_type SubType , f.rdb$character_length CharSize, trim(rf.rdb$field_source) FieldSource, rf.rdb$null_flag NullFlag, f.rdb$field_precision FieldPrecision, f.rdb$field_scale FieldScale, f.rdb$field_length FieldLength " +
                        "from rdb$relation_fields rf " +
                        "join rdb$relations r on rf.rdb$relation_name = r.rdb$relation_name " +
                                            "and r.rdb$view_blr is not null " +
                                            "and r.rdb$relation_type = 1 and r.rdb$system_flag = 0 " +
                        "join rdb$fields f on f.rdb$field_name = rf.rdb$field_source " +
                     $"where rf.rdb$relation_name = '{this.ViewName}' " +
                      "order by rf.rdb$field_position; ";
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    var size = (reader["CharSize"] == DBNull.Value) ? null : (short?)reader["CharSize"];
                    var subType = (reader["SubType"] == DBNull.Value) ? null : (short?)reader["SubType"];
                    var nullFlag = reader["NullFlag"] == DBNull.Value;
                    var precision = (reader["FieldPrecision"] == DBNull.Value) ? null : (short?)reader["FieldPrecision"];
                    var scale = (reader["FieldScale"] == DBNull.Value) ? null : (short?)reader["FieldScale"];
                    var fieldLength = (reader["FieldLength"] == DBNull.Value) ? null : (short?)reader["FieldLength"];
                    var type = new FieldType((short)reader["Type"], subType, size, precision, scale, fieldLength);

                    yield return new ColumInfo((string)reader["Name"], type, null, (string)reader["FieldSource"], nullFlag, true, "");
                }
            }
        }
 public DomainInfo(string name, FieldType type, string validationSource, string dafaultSource, bool isNullFlag)
 {
     DomainName = name;
     DomainType = type;
     ValidationSource = validationSource;
     DefaultSource = dafaultSource;
     IsNullFlag = isNullFlag;
 }
예제 #3
0
        public IEnumerable<ColumInfo> GetColums(FbConnection con)
        {
            var constraints = GetConstrains(con);

            using (var command = con.CreateCommand())
            {
                command.CommandText =
                    $"select trim(rf.rdb$field_name) Name, f.rdb$field_type Type, f.rdb$field_sub_type SubType , f.rdb$character_length CharSize, trim(rf.rdb$field_source) FieldSource, rf.rdb$null_flag NullFlag, f.rdb$null_flag fieldNullFlag, f.rdb$field_precision FieldPrecision, f.rdb$field_scale FieldScale, f.rdb$field_length FieldLength, coalesce(rf.rdb$default_source, '') DefaultSource " +
                        "from rdb$relation_fields rf " +
                        "join rdb$relations r on rf.rdb$relation_name = r.rdb$relation_name " +
                                            "and r.rdb$view_blr is null " +
                                            $"and r.rdb$relation_type = 0 and r.rdb$system_flag = {SystemFlag} " +
                        "join rdb$fields f on f.rdb$field_name = rf.rdb$field_source " +
                    $"where rf.rdb$relation_name = '{this.TableName}' " +
                     "order by rf.rdb$field_position; ";
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    var name = (string)reader["Name"];
                    var size = (reader["CharSize"] == DBNull.Value) ? null : (short?)reader["CharSize"];
                    var subType = (reader["SubType"] == DBNull.Value) ? null : (short?)reader["SubType"];
                    var nullFlag = reader["NullFlag"] == DBNull.Value;
                    var fieldNullFlag = reader["FieldNullFlag"] == DBNull.Value;
                    var precision = (reader["FieldPrecision"] == DBNull.Value) ? null : (short?)reader["FieldPrecision"];
                    var scale = (reader["FieldScale"] == DBNull.Value) ? null : (short?)reader["FieldScale"];
                    var fieldLength = (reader["FieldLength"] == DBNull.Value) ? null : (short?)reader["FieldLength"];
                    var type = new FieldType((short)reader["Type"], subType, size, precision, scale, fieldLength);
                    var defaultSource = (string)reader["DefaultSource"];

                    var constraintInfo = new ColumConstraintsInfo();
                    if (constraints.ContainsKey(name))
                    {
                        constraintInfo = constraints[name];
                    }

                    yield return new ColumInfo(name, type, constraintInfo, (string)reader["FieldSource"], nullFlag, fieldNullFlag, defaultSource);
                }
            }
        }
 public IEnumerable<DomainInfo> GetDomain(FbConnection con)
 {
     using (var command = con.CreateCommand())
     {
         command.CommandText =
              $"select distinct f.rdb$field_type Type, f.rdb$field_sub_type SubType , f.rdb$character_length CharSize, trim(f.rdb$field_name) FieldName, f.rdb$field_precision FieldPrecision, f.rdb$field_scale FieldScale, f.rdb$field_length FieldLength, coalesce(f.rdb$validation_source, '') ValidationSource, coalesce(f.rdb$default_source, '') DefaultSource, f.rdb$null_flag NullFlag " +
               "from rdb$fields f " +
              $"where f.rdb$FIELD_NAME not starting with 'RDB$' and f.rdb$FIELD_NAME not starting with 'MON$' and f.rdb$FIELD_NAME not starting with 'SEC$' " +
               "order by f.rdb$field_name; ";
         var reader = command.ExecuteReader();
         while (reader.Read())
         {
             var name = (string)reader["FieldName"];
             var size = (reader["CharSize"] == DBNull.Value) ? null : (short?)reader["CharSize"];
             var subType = (reader["SubType"] == DBNull.Value) ? null : (short?)reader["SubType"];
             var precision = (reader["FieldPrecision"] == DBNull.Value) ? null : (short?)reader["FieldPrecision"];
             var scale = (reader["FieldScale"] == DBNull.Value) ? null : (short?)reader["FieldScale"];
             var fieldLength = (reader["FieldLength"] == DBNull.Value) ? null : (short?)reader["FieldLength"];
             var type = new FieldType((short)reader["Type"], subType, size, precision, scale, fieldLength);
             var validationSource = (string)reader["ValidationSource"];
             var defaultSource = (string)reader["DefaultSource"];
             var nullFlag = reader["NullFlag"] == DBNull.Value;
             yield return new DomainInfo(name, type, validationSource, defaultSource, nullFlag);
         }
     }
 }