Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> IsDirty and PrefetchPath
 

Pages: 1
LLBLGen Pro Runtime Framework
IsDirty and PrefetchPath
Page:1/1 

  Print all messages in this thread  
Poster Message
obzekt
User



Location:

Joined on:
29-Apr-2004 18:18:59
Posted:
49 posts
# Posted on: 14-Jan-2010 13:37:52.  
Hello. I noticed that if I load an entity by calling FetchUsingPK and specifying a prefetch path, the IsDirty property of the entity is raised to True. It remains False if no prefetch path is specified. Is that by design? If yes, why that happens?

I'm using SelfServicing and runtime v2.6.10.105.
  Top
MTrinder
User



Location:
London by day, Milton Keynes by night.
Joined on:
08-Oct-2008 17:55:47
Posted:
1461 posts
# Posted on: 14-Jan-2010 23:49:20.  
Is this the .IsDirty property of the entity at the top of the graph ?
Can you post a code snippit which demonstrates how you are calling this ?

Thanks

Matt


  Top
obzekt
User



Location:

Joined on:
29-Apr-2004 18:18:59
Posted:
49 posts
# Posted on: 15-Jan-2010 07:44:18.  
Here's an example:

Code:

PrefetchPath path = new PrefetchPath(EntityType.ReportEntity);
path.Add(ReportEntity.PrefetchPathSiteWorkType);
ReportEntity re = new ReportEntity();
if (!re.FetchUsingPK(reportID, path, null, null))
     throw new Exception(string.Format("The specified report {0} cannot be found.", reportID));

// Reset the dirty flag because loading the entity with a prefetch path makes it 'dirty'.
// Not sure if it's LLBL by design or not but we don't want that.
re.IsDirty = false;


The relation between Report and SiteWorkType is via a Report.SiteWorkTypeID FK.
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14585 posts
# Posted on: 15-Jan-2010 09:05:13.  
Reproduced.
We are looking into it.


  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37869 posts
# Posted on: 15-Jan-2010 10:07:37.  
Odd indeed. The FK field is marked as dirty. So when I do:
Code:

[Test]
public void FetchWithPrefetchPathIsDirtyTest()
{
    PrefetchPath path = new PrefetchPath(EntityType.OrderEntity);
    path.Add(OrderEntity.PrefetchPathCustomers);
    OrderEntity o = new OrderEntity();
    Assert.IsFalse(o.IsDirty);
    Assert.IsTrue(o.IsNew);
    Assert.IsTrue(o.FetchUsingPK(10254, path));
    foreach(EntityField field in o.Fields)
    {
        if(field.IsChanged)
        {
            Console.WriteLine("Field '{0}' is marked as changed", field.Name);
        }
    }
    Assert.IsFalse(o.IsDirty); // <<<< fails.
    Assert.IsFalse(o.IsNew);
}

It will say 'CustomerId' and fail on the isdirty assert.

When I do:
Code:

[Test]
public void FetchWithPrefetchPathIsDirtyTest2()
{
    PrefetchPath path = new PrefetchPath(EntityType.OrderEntity);
    path.Add(OrderEntity.PrefetchPathCustomers);
    OrderCollection orders = new OrderCollection();
    Assert.IsTrue(orders.GetMulti((OrderFields.OrderId == 10254), path));
    Assert.AreEqual(1, orders.Count);
    OrderEntity o = orders[0];
    foreach(EntityField field in o.Fields)
    {
        if(field.IsChanged)
        {
            Console.WriteLine("Field '{0}' is marked as changed", field.Name);
        }
    }
    Assert.IsFalse(o.IsDirty);
    Assert.IsFalse(o.IsNew);
}

then IsDirty is not set. So it's not the prefetch path code, but I suspect the order in which things happen, will look into it.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37869 posts
# Posted on: 15-Jan-2010 10:26:36.  
Fixed it. The internal method doing the fixing was fetching the prefetch path before the entity was marked as fetched (it was still 'new'), so Fk syncing took place. Strange that this bug has been in the code for so long (4-5 years). See attached dll.

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
obzekt
User



Location:

Joined on:
29-Apr-2004 18:18:59
Posted:
49 posts
# Posted on: 15-Jan-2010 16:56:38.  
Glad you found it. Thanks for the quick response!
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.