Page 1 of 2

PropertyChanging NullReferenceException DateTime Field

Posted: Wed 08 Jul 2009 16:46
by infinitep
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.

Posted: Thu 09 Jul 2009 14:06
by AndreyR
This problem is fixed. Look forward to the upcoming build.

Posted: Wed 15 Jul 2009 18:26
by infinitep
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.

Posted: Thu 16 Jul 2009 08:24
by AndreyR
Could you please make a small test project illustrating the problem?
Send it to support * devart * com with subject "LINQ: DateTime PropertyChanging".

Posted: Wed 26 Aug 2009 11:17
by alfmos
the error is also in 5.40.39

Posted: Thu 27 Aug 2009 09:34
by Shalex
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 .

Posted: Thu 03 Sep 2009 13:34
by infinitep
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.

Posted: Thu 03 Sep 2009 15:57
by Shalex
Infinitep, we have answered you by e-mail.

Posted: Thu 03 Sep 2009 18:26
by infinitep
project emailed, most likely cause updating the same field in DDD when saving table. This works in MSSQL though.

Posted: Fri 04 Sep 2009 15:19
by Shalex
The problem is fixed. Look forward to the next build.

Posted: Tue 15 Sep 2009 17:14
by alfmos
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

Posted: Thu 17 Sep 2009 08:36
by AndreyR
We have reproduced the problem. I will let you know about the results of our investigation.

Posted: Thu 24 Sep 2009 11:33
by alfmos
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

Posted: Thu 24 Sep 2009 14:49
by AndreyR
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).

Posted: Fri 25 Sep 2009 13:52
by alfmos
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