IsDirty & Managed Child fieldsIsDirty & Managed Child fields
Old forum URL: forums.lhotka.net/forums/t/7076.aspx
Pawz posted on Wednesday, June 10, 2009
Hi,
I've got an odd scenario that's been happening and I'm not sure if it's by design and I'm missing something, or if I'm just missing something in my code in general.
It's the basic root + child list + child scenario, with lazy loading of the child list
Company -> TradingNames -> TradingName.
Property in company:
public CompanyTradingNames TradingNames
{
get
{
if (!FieldManager.FieldExists(CompanyTradingNamesProperty))
{
if (IsNew)
LoadProperty(CompanyTradingNamesProperty, CompanyTradingNames.NewTradingNames());
else
LoadProperty(CompanyTradingNamesProperty,
CompanyTradingNames.GetTradingNamesFromCompanyAsParent(Id));
}
return GetProperty(CompanyTradingNamesProperty);
}
}
Company.DataPortal_Update() calls
FieldManager.UpdateChildren(this, DM); // Passes in reference to the SQL manager object I'm using
However, this test fails:
[Test]
public void TestingIsDirtyOnChildObjects()
{
_company = _company.Save();
Assert.IsFalse(_company.IsDirty);
CompanyTradingName n = _company.TradingNames.AddNewTradingName();
Assert.IsTrue(_company.IsDirty);
n.TradingName = "test";
//_company.Notes = "These are new notes"; //Test passes if uncommented
_company = _company.Save();
n = _company.TradingNames[0];
Assert.IsFalse(_company.IsDirty); // Fails here
n.TradingName = "Testing Dirty";
Assert.IsTrue(_company.IsDirty);
}
If I uncomment the //_company.Notes line, the test passes. I'm not really sure what's going wrong!
If anyone has an idea I would appreciate the help.
Copyright (c) Marimer LLC