Skip to content

Instantly share code, notes, and snippets.

@SzymonPobiega
Created January 15, 2012 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SzymonPobiega/1617321 to your computer and use it in GitHub Desktop.
Save SzymonPobiega/1617321 to your computer and use it in GitHub Desktop.
Here's how you use ReferenceDataManager
ObjectId hierarchyId;
var builder = new ChangeSetBuilder(objectFacade, null);
{
var hierarchy = builder.CreateHierarchy();
hierarchyId = hierarchy.Id;
var parentUnit = builder.CreateUnit("Parent", new Address("Lubicz", "23", "Krakow", "PL"));
var childUnit = builder.CreateUnit("Child", null);
builder.SetHierarchyRoot(hierarchy, parentUnit);
builder.SetParent(hierarchy, childUnit, parentUnit);
}
var view = objectFacade.GetSnapshot(builder.PendingChanges);
{
var hierarchy = view.GetById<Hierarchy>(hierarchyId);
var rootUnit = hierarchy.RootUnit;
var childUnits = hierarchy.RootUnit.GetChildrenWithin(hierarchy);
var firstChildUnit = childUnits.First();
Assert.AreEqual("Parent", rootUnit.Name);
Assert.AreEqual(new Address("Lubicz", "23", "Krakow", "PL"), rootUnit.Address);
Assert.AreEqual("Child", firstChildUnit.Name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment