Odd indeed. The FK field is marked as dirty. So when I do:
[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:
[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.