Data is null on DbGenerated column
Posted: Sun 20 Apr 2014 10:21
Our model features a column defined as:
<Column Name="XY" Type="System.String" AutoSync="Always" DbType="NVARCHAR(20)" IsDbGenerated="true" CanBeNull="true" UpdateCheck="Never" MaxLength="20" Unicode="true" ed:ValidateMaxLength="20" ed:ValidateRequired="False"/>
On insert the column is selected back. In some cases the value should be null. In these cases we get an exception:
at System.Data.SqlClient.SqlBuffer.get_String()
at System.Data.SqlClient.SqlDataReader.GetString(Int32 i)
at Devart.Data.Linq.DataProvider.ReadValue(IDataReader reader, Type type, Int32 fieldInd)
at Devart.Data.Linq.DataProvider.b(String A_0, IEnumerable`1 A_1, IEnumerable`1 A_2, Boolean A_3)
at Devart.Data.Linq.DataProvider.a(String A_0, IEnumerable`1 A_1, IEnumerable`1 A_2, Boolean A_3)
at Devart.Data.Linq.Engine.SubmitCommandBuilder.a(IObjectEntry A_0)
at Devart.Data.Linq.Engine.b5.a(IObjectEntry[] A_0, ConflictMode A_1, a A_2)
at Devart.Data.Linq.Engine.b5.a(ConflictMode A_0)
at Devart.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at Devart.Data.Linq.DataContext.SubmitChanges()
Is this behavior by design? Is there something we can do to prevent this?
In short, on insert the generated field is and should be null, the query works fine, the exception is thrown as Linq data provider expects it not to be null.
We have upgraded to the lates version of linq and dotConnect.
<Column Name="XY" Type="System.String" AutoSync="Always" DbType="NVARCHAR(20)" IsDbGenerated="true" CanBeNull="true" UpdateCheck="Never" MaxLength="20" Unicode="true" ed:ValidateMaxLength="20" ed:ValidateRequired="False"/>
On insert the column is selected back. In some cases the value should be null. In these cases we get an exception:
at System.Data.SqlClient.SqlBuffer.get_String()
at System.Data.SqlClient.SqlDataReader.GetString(Int32 i)
at Devart.Data.Linq.DataProvider.ReadValue(IDataReader reader, Type type, Int32 fieldInd)
at Devart.Data.Linq.DataProvider.b(String A_0, IEnumerable`1 A_1, IEnumerable`1 A_2, Boolean A_3)
at Devart.Data.Linq.DataProvider.a(String A_0, IEnumerable`1 A_1, IEnumerable`1 A_2, Boolean A_3)
at Devart.Data.Linq.Engine.SubmitCommandBuilder.a(IObjectEntry A_0)
at Devart.Data.Linq.Engine.b5.a(IObjectEntry[] A_0, ConflictMode A_1, a A_2)
at Devart.Data.Linq.Engine.b5.a(ConflictMode A_0)
at Devart.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at Devart.Data.Linq.DataContext.SubmitChanges()
Is this behavior by design? Is there something we can do to prevent this?
In short, on insert the generated field is and should be null, the query works fine, the exception is thrown as Linq data provider expects it not to be null.
We have upgraded to the lates version of linq and dotConnect.