Exception using DeleteOnSubmit

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
KlausRoed
Posts: 1
Joined: Wed 21 Feb 2018 18:06

Exception using DeleteOnSubmit

Post by KlausRoed » Wed 21 Feb 2018 18:24

Hi

I am using version 9.5.454 of Devart.Data.Oracle and 4.8.1423 of Devart.Data.Oracle.Linq in a dotnet core 2.0.5 asp.net application, and I have a made a generic delete function where an object is given to the function as parameter (item):

Code: Select all

var sourceTable = mOtc.InnerDbContext.GetTable(typeof(T));
sourceTable.Attach(item, true);
sourceTable.DeleteOnSubmit(item);
mOtc.InnerDbContext.SubmitChanges();
The object item contains a valid object that also exists in the database. - I have off cause debugged the code and I am sure it is valid. The primary key in the table is a 4 character varchar2.

When submitting changes Devart.Data.Linq throws an exception:

Code: Select all

System.ArgumentNullException: Value cannot be null.
Parameter name: key
   at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Collections.Generic.Dictionary`2.Remove(TKey key)
   at Devart.Data.Linq.Engine.el.e(IObjectEntry A_0)
   at Devart.Data.Linq.Engine.c7.b(IObjectEntry A_0)
   at Devart.Data.Linq.Engine.dl.h()
   at Devart.Data.Linq.Engine.dz.a(ConflictMode A_0)
   at Devart.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
   at LeanfidsModel.CachedList`1.Remove(T item) in C:\Users\klaus\Documents\Visual Studio 2017\Projects\LeanfidsApi\LeanfidsModel\CachedList.cs:line 286
The entity model contains this definition for the primary key:

Code: Select all

 [Column(Name = @"AIRPORT_CODE", Storage = "_AIRPORTCODE", CanBeNull = false, DbType = "VARCHAR2(4 CHAR) NOT NULL", IsPrimaryKey = true)]
I am not able to figure out why this happens. Anyone able to help ?

Pinturiccio
Devart Team
Posts: 2192
Joined: Wed 02 Nov 2011 09:44

Re: Exception using DeleteOnSubmit

Post by Pinturiccio » Mon 26 Feb 2018 14:42

Try using

Code: Select all

sourceTable.Attach(item);
instead of

Code: Select all

sourceTable.Attach(item, true);
If it does not help, create and send us a small test project, which reproduces the issue.

Post Reply