EntityRef new behaviour or Regression?

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
bmarotta
Posts: 34
Joined: Wed 29 Sep 2010 11:27

EntityRef new behaviour or Regression?

Post by bmarotta » Thu 30 Sep 2010 18:19

Hi,

we are testing our application with the new 5.70.170 version and we found a different behavior from the last version we were using (5.60.124).

We have a class like this

Code: Select all

[Table(Name = @"PUMA_WORKITEM")]
    public partial class WorkItem : INotifyPropertyChanging, INotifyPropertyChanged    {
...
[Association(Name="Task_WorkItem", Storage="_Task", ThisKey="TaskId", IsForeignKey=true)]
        public Task Task
(...)
On the old version, while trying to check if a workitem had a Task, we did:

Code: Select all

if (item.Task == null)
On the new version, this always return false, even if the TaskId is set for the workitem. We found that one of the reasons may be because in another part of the code we did:

Code: Select all

context.WorkItems.LoadWith(n => n.Task)
In this case the (item.Task == null) works correctly. We think somehow, the Devart engine is saving the LoadWith information.

If we delete the above mentioned LoadWith statement than everything works fine. The problem is that we cannot go throughout our entire code deleting the LoadWith or always adding the LoadWith...

Could you please check this?

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 01 Oct 2010 13:25

Could you please describe the scenario in which you are encountering the problem in more details? For example, if you are serializing and deserializing WorkItem objects, the related Task objects should not be loaded by default, hence item.Task will always be null. When the WorkItems.LoadWith method is used, it is specified that the related Task entities should be loaded immendiately and hence they will be passed through serialization/deserialization.

If possible, please send us a small test project with which the problem can be reproduced.

bmarotta
Posts: 34
Joined: Wed 29 Sep 2010 11:27

Post by bmarotta » Fri 01 Oct 2010 17:58

Hi Stanislav,

it is hard to send a small example, because our project is huge.

What I can tell is that previously the workitem.Task was not null even without the LoadWith. If you say this is suppose to be like this than it is a new feature, meaning that we will have to go throughout our whole code and add LoadWith for all entities that previously were loaded on demand.

What I can tell you also is that in many parts of the code, we have a similar relationship, and the entity is not set to null. It is only set to null if, somewhere in the code you do a LoadWith and than in another part of the code, with a completely different context, you don't do it.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Mon 04 Oct 2010 15:08

I will send you a test project in a letter, please check that it is not blocked by your mail filter.

In the sample, there is a model built on a master/detail association. Two data contexts for this model are created, one of them uses LoadWith(), another does not. The master object is loaded from a detail entity properly in both cases. Please specify what should be changed in the sample to reproduce the problem.

bmarotta
Posts: 34
Joined: Wed 29 Sep 2010 11:27

Post by bmarotta » Thu 21 Oct 2010 13:02

Hi Stanislaw,

I tried to send you an e-mail, but your mailbox is full. We managed to reproduce the error using your sample. Here is how to do it:

Here is how to reproduce the issue with LoadWith() on the example from Devart:

1) In the Load1()
change:

Code: Select all

dc.Emps.LoadWith(e => e.Dept);        
Console.WriteLine("First context: related Dept is {0} null", dc.Emps.FirstOrDefault().Dept == null ? "" : "not");
With:

Code: Select all

Console.WriteLine("First context: related Dept is {0} null", dc.Emps.LoadWith(e => e.Dept).FirstOrDefault().Dept == null ? "" : "not");
//call of the 2nd thread here!
Thread th2 = new Thread(Load2);
th2.Start();

2) In the Main()

remove or comment :

Code: Select all

      // Thread th2 = new Thread(Load2);
      // th2.Start();
Please let me know if you manage to reproduce it (or when your mailbox is back again)

Best regards,

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 22 Oct 2010 10:16

Thank you for your assistance, we have reproduced the issue. We will investigate it and inform you about the results here.

As for the mail box, did you send the letter to support * devart * com or to some other address? It is recommended to write to the first one instead of using personal mailboxes, as we are using a request tracking system, and it will be easier to track your letter(s) in this case.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 04 Nov 2010 17:47

We have fixed the problem with the LoadWith method, the fix is available in the latest 5.70.190 build of dotConnect for Oracle.

The build can be downloaded from
http://www.devart.com/dotconnect/oracle/download.html
(the trial version) or from Registered Users' Area (for users with active subscription only):
http://secure.devart.com/

For the detailed information about the improvements and fixes available in dotConnect for Oracle 5.70.190, please refer to
http://www.devart.com/forums/viewtopic.php?t=19420

Post Reply