PropertyChanging NullReferenceException DateTime Field

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
infinitep
Posts: 17
Joined: Wed 08 Jul 2009 16:31

PropertyChanging NullReferenceException DateTime Field

Post by infinitep » Wed 08 Jul 2009 16:46

I am using 5.20.33 trial. I get the following error;

[NullReferenceException: Object reference not set to an instance of an object.]
lambda_method(ExecutionScope , Object ) +29
Devart.Data.Linq.s.a(Object A_0) +57
Devart.Data.Linq.e.a(Object A_0) +40
Devart.Data.Linq.e.a(h A_0, Object A_1, Boolean A_2) +132
Devart.Data.Linq.e.a(h A_0, Object A_1, Boolean A_2, Boolean A_3) +131
Devart.Data.Linq.j.a(h A_0, Object A_1, Boolean A_2, Boolean A_3) +79
Devart.Data.Linq.j.g(h A_0) +43
Devart.Data.Linq.r.a(Object A_0, PropertyChangingEventArgs A_1) +45
cn.ProjectCore.Core.Domain.account.SendPropertyChanging()
cn.ProjectCore.Core.Domain.account.set_lastlogindate(Nullable`1 value)
cn.ProjectCore.Core.DataAccess.Impl.AccountRepository.SaveLastLogin(account account)



When excuting this code;


public void SaveLastLogin(account account)
{
using (ProjectDataContext dc = conn.GetContext())
{
account.lastlogindate = DateTime.Now;
if (account.accountid > 0)
{
dc.accounts.Attach(account, true);
}
dc.SubmitChanges();
}
}



The datetime field allows nulls. Anyone know why this occuring? Thanks.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 09 Jul 2009 14:06

This problem is fixed. Look forward to the upcoming build.

infinitep
Posts: 17
Joined: Wed 08 Jul 2009 16:31

Post by infinitep » Wed 15 Jul 2009 18:26

Doesn't seem to be fixed in 5.40.37

Now I get the following.

[NullReferenceException: Object reference not set to an instance of an object.]
lambda_method(ExecutionScope , Object ) +29
Devart.Data.Linq.s.a(Object A_0) +57
Devart.Data.Linq.e.a(Object A_0) +40
Devart.Data.Linq.e.a(h A_0, Object A_1, Boolean A_2) +132
Devart.Data.Linq.e.a(h A_0, Object A_1, Boolean A_2, Boolean A_3) +131
Devart.Data.Linq.j.a(h A_0, Object A_1, Boolean A_2, Boolean A_3) +91
Devart.Data.Linq.j.g(h A_0) +43
Devart.Data.Linq.r.a(Object A_0, PropertyChangingEventArgs A_1) +45
CN.ProjectCore.Core.Domain.account.SendPropertyChanging()
CN.ProjectCore.Core.Domain.account.set_lastlogindate(Nullable`1 value)
CN.ProjectCore.Core.DataAccess.Impl.AccountRepository.SaveLastLogin(account account)


I think it could be something to do with my Domain Driven Design. Also note that project works fine with microsoft linq and sql server.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 16 Jul 2009 08:24

Could you please make a small test project illustrating the problem?
Send it to support * devart * com with subject "LINQ: DateTime PropertyChanging".

alfmos
Posts: 6
Joined: Wed 26 Aug 2009 11:12

Post by alfmos » Wed 26 Aug 2009 11:17

the error is also in 5.40.39

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

Post by Shalex » Thu 27 Aug 2009 09:34

Alfmos, could you please send us a small test project to reproduce the error? Please contact us via our contact form http://www.devart.com/company/contact.html .

infinitep
Posts: 17
Joined: Wed 08 Jul 2009 16:31

Post by infinitep » Thu 03 Sep 2009 13:34

Sorry I have been so busy and couldnt do this. But if you still require a sample app I will need to reset my trail as it has expired. I would still like to fully test dotconnect with my project as I see great potential with it, but for me, mssql is such more user friendly than mysql. Though for the price mysql is a winner.

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

Post by Shalex » Thu 03 Sep 2009 15:57

Infinitep, we have answered you by e-mail.

infinitep
Posts: 17
Joined: Wed 08 Jul 2009 16:31

Post by infinitep » Thu 03 Sep 2009 18:26

project emailed, most likely cause updating the same field in DDD when saving table. This works in MSSQL though.

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

Post by Shalex » Fri 04 Sep 2009 15:19

The problem is fixed. Look forward to the next build.

alfmos
Posts: 6
Joined: Wed 26 Aug 2009 11:12

Post by alfmos » Tue 15 Sep 2009 17:14

Shalex wrote:Alfmos, could you please send us a small test project to reproduce the error? Please contact us via our contact form http://www.devart.com/company/contact.html .
Hi we did send today a little project reproducing the bug.
Also, in our production code we have another error, like the one signaled in this thread, on the same class.
We have updated to version 5.40.42 (wouldn't be possible that you create patches or updates, so we don't need to uninstall and reinstall everything to every new version?:))
It seems to us that the problem arises when we define a partial class to extend an object mapped with devart linq.
Hope you'll find quickly a solution, because we now must do insert and updates by hand.
Regards
Alfonso Moscato

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 17 Sep 2009 08:36

We have reproduced the problem. I will let you know about the results of our investigation.

alfmos
Posts: 6
Joined: Wed 26 Aug 2009 11:12

Post by alfmos » Thu 24 Sep 2009 11:33

AndreyR wrote:We have reproduced the problem. I will let you know about the results of our investigation.
Hi Andrey, any news?
we have great difficulties operating with this bug.
I would have expected as a paying user (code:dcmysql5pro) that you resolve critical bugs in a reasonable timeframe.
We tried also to switch to EF, but we found a bug also there.
So can you give us some prevision about bug resolution?
regards
Alfonso Moscato

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 24 Sep 2009 14:49

We have fixed the problem with the exception, but the scenario you describe is erroneous, it will cause the
"An entity can only be attached as modified without original state if it declares a version member or
does not have an update check policy" error.
I recommend you either to declare a version member in your model for the entity you want to attach,
or to pass the original state of the entity to the Attach call (make a memberwise copy
before making changes to the entity you are passing to the Attach method).

alfmos
Posts: 6
Joined: Wed 26 Aug 2009 11:12

Post by alfmos » Fri 25 Sep 2009 13:52

Hi Andrey, thanks for the answer.
I think i'll get updates in the dotConnect for MySQL 5.40.44, right?
Please, can you explain me exactly why described scenario was wrong?
I used a normal table and, after generation of relate class, extend it with partial class (perhaps with fields mapped (and unmapped) directly to database table columns).
If i use table as is (without partial class), i don't have the same exception.
So i need to understand if solution that you propose is a workaround or there is a guidelines that i don't know :D.
Thank you very much for your collaboration
Best Regards
Alfonso Moscato

Post Reply