PropertyChanging NullReferenceException DateTime Field
PropertyChanging NullReferenceException DateTime Field
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.
[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.
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.
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.
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 .
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.
Hi we did send today a little project reproducing the bug.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 .
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
Hi Andrey, any news?AndreyR wrote:We have reproduced the problem. I will let you know about the results of our investigation.
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
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).
"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).
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 .
Thank you very much for your collaboration
Best Regards
Alfonso Moscato
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 .
Thank you very much for your collaboration
Best Regards
Alfonso Moscato