NullReferenceException on updating any values

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
LordXaosa
Posts: 2
Joined: Mon 15 Oct 2018 11:23

NullReferenceException on updating any values

Post by LordXaosa » Mon 15 Oct 2018 11:32

Hello.
I'm using PostgreSQL.Linq. If i'm using any entity that has foreign key and adding both to model then if I try to update any values in loaded entity - it will throw NullReferenceException in SendPropertyChanging method.
Example:

Code: Select all

CREATE TABLE public.test_link
(
    id serial NOT NULL,
    test_date timestamp with time zone NOT NULL,
    test_val text COLLATE pg_catalog."default",
    CONSTRAINT test_link_pkey PRIMARY KEY (id)
)
CREATE TABLE public.test
(
    id serial NOT NULL,
    my_date timestamp with time zone NOT NULL,
    test text COLLATE pg_catalog."default" NOT NULL,
    test_link integer,
    CONSTRAINT test_pkey PRIMARY KEY (id),
    CONSTRAINT test_fk FOREIGN KEY (test_link)
        REFERENCES public.test_link (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)
and then in code I'm trying to do simple thing:

Code: Select all

using (postgresModel db = new postgresModel())
{
       var log = db.Tests.FirstOrDefault();
       log.MyDate = DateTime.Now;//exception is here. Updating of text column (or any other) throws exception too
       db.SubmitChanges();
}
Workaround: disable foreign keys and delete associations, then updating works fine. StrongReference option doesn't help.
Devart.Data.PostgreSql.Linq v4.8.1566
NetCore 2.1.4

Code: Select all

-		$exception	{System.NullReferenceException: Object reference not set to an instance of an object.
   at   .(ILGenerator , MetaType )
   at   .(MetaType )
   at Devart.Data.Linq.Mapping.MetaType.()
   at Devart.Data.Linq.Mapping.MetaType.(Object )
   at  .3nxbbzw4xerph56q55jgvex7tkhjgxtn  ​ ()
   at  .(Object , PropertyChangingEventArgs )
   at PostgreContext.Test.SendPropertyChanging(String propertyName) in C:\Users\LordXaosa\source\repos\PGTest\PGTest\DB.Designer.cs:line 479
   at PostgreContext.Test.set_Test1(String value) in C:\Users\LordXaosa\source\repos\PGTest\PGTest\DB.Designer.cs:line 390
   at PGTest.Program.Main(String[] args) in C:\Users\LordXaosa\source\repos\PGTest\PGTest\Program.cs:line 15}	System.NullReferenceException

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: NullReferenceException on updating any values

Post by Shalex » Wed 17 Oct 2018 17:43

Thank you for your report. We have reproduced the issue and are investigating it. We will notify you about the result.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: NullReferenceException on updating any values

Post by Shalex » Thu 25 Oct 2018 16:44

The bug with updating the existing entities that participate in FK associations is fixed in .NET Standard 2 compliant assemblies: viewtopic.php?f=31&t=37914.

LordXaosa
Posts: 2
Joined: Mon 15 Oct 2018 11:23

Re: NullReferenceException on updating any values

Post by LordXaosa » Mon 29 Oct 2018 07:59

Thanks!
Confirm, it works fine now.

Post Reply