Integer[] value cannot be inserted into a PostgreSql database with LinqConnect
Hello,
We have a column with datatype integer[] in one of our database tables.
Using repository pattern, when we run this code:
- OurTableEntity entity = new OurTableEntity();
entity.OurColumn = "{-1,-1,-1,-1,-1}";
ourTableRepository.Add(entity);
unitOfWork.Save(); // dataContext.SubmitChanges();
The SubmitChanges will throw an exception:
Inner Exception 1:
- LinqCommandExecutionException: Error on executing DbCommand.
Inner Exception 2:
- InvalidCastException: Cannot convert parameter value of type 'System.String' to PostgreSQL type 'PgSqlType.Int'.
Same outcome, when I modify a queried entity's 'OurColumn' and then call SubmitChanges().
A query like repository.GetAll() works properly.
In C# we have this auto generated code for the column:
- [Column(Name = @"our_column", Storage = "_OurColumn", DbType = "INT4[]", UpdateCheck = UpdateCheck.Never)]
- public object OurColumn
- {
- get
- {
- return this._OurColumn;
- }
- set
- {
- if (this._OurColumn != value)
- {
- this.OnLotGroupsChanging(value);
- this.SendPropertyChanging("OurColumn");
- this._OurColumn = value;
- this.SendPropertyChanged("OurColumn");
- this.OnLotGroupsChanged();
- }
- }
- }
And we have the code below in the database.lqml file:
- <Column Name="our_column" Member="OurColumn" Type="System.Object" DbType="INT4[]" CanBeNull="true" UpdateCheck="Never" DefaultValue="'{-1,-1,-1,-1,-1}'::integer[]" ed:ValidateRequired="false" ed:Guid="91a849ae-cd37-4273-ab4b-d901c5ea093e" />
We have a datacontext log:
INSERT INTO public.our_table (our_column, id) VALUES (:p1, nextval('seq_custom_sequence')) RETURNING id
-- p1: Input Int (Size = 16; DbType = Int32) [{-1,-1,-1,-1,-1}]
Project: C# .NET Framework 4.8
Devart.Data: 5.0.2531.0
Devart.Data.Linq: 4.9.2076.0
Devart.Data.PostgreSql: 7.18.1739.0
Devart.Data.PostgreSql.Linq: 4.9.2076.0
It looks like that linqConnect tries to cast this string to integer, instead of integer[].
Please help us with this issue!
Best regards,
Gabor