henkmollema / Dommel

CRUD operations with Dapper made simple.
MIT License
611 stars 99 forks source link

Insert column with type of array #286

Closed mbtolou closed 1 year ago

mbtolou commented 1 year ago

Hi. I create table with _varchar(string[]) type in Postgres .

[Table("tbl_profile_channel")]
public class ProfileChannelModel 
{
  #region Columns
  public long id { get; set; }
  public long channel_hash { get; set; }
  public string obis_code { get; set; }
  public long profile_group_hash { get; set; }
  public short lag_hour_jump { get; set; }
  public short query_date_days_ago { get; set; }
  public bool ctpt_scale { get; set; }
  public string[] cols_obis_list { get; set; }
}

when query this table data return successfully . csharp var ta = AppConfig.GetPgqlConn().GetAll<DbEntity.Models.ProfileChannelModel>();

but when try insert data into . throw exception :

      AppConfig.GetPgqlConn().Insert(
        new DbEntity.Models.ProfileChannelModel
        {
          cols_obis_list = new string[] { "test", "next" },
          obis_code = "123",
          channel_hash = 120,
          lag_hour_jump = 5,
          query_date_days_ago = 5,
          ctpt_scale = true,
          profile_group_hash = 12
        });

when change my class property with array type to object ,both of query (Insert ,Update) work successfully.

[Table("tbl_profile_channel")]
public class ProfileChannelModel 
{
  #region Columns
  public long id { get; set; }
  public long channel_hash { get; set; }
  public string obis_code { get; set; }
  public long profile_group_hash { get; set; }
  public short lag_hour_jump { get; set; }
  public short query_date_days_ago { get; set; }
  public bool ctpt_scale { get; set; }
  public object cols_obis_list { get; set; }  // <======= this is changed from string[] to object
}
henkmollema commented 1 year ago

What exception does it throw?