Hierarchy Rules

These rules can be applied between a property of an owned type and a property of the owner.

class Parent
    public Guid Id { get; private set; }
    public Child MyChild { get; set; }

class Child
    public Guid ParentId { get; set; }


Set a property of an owned type to have the same value as a property of the owner.

var sampleData = Fabricator.Setup<SampleData>()
                           .ForChild(x => x.MyChild).Link(c => c.ParentId).To(x => x.Id)

// sampleData.ParentId= sampleData.MyChild.ParentId

  • If a parent=>child link results in recursion an unspecified number of items will be populated before Fabricator will skip population to prevent a stack overflow

Last edited Nov 21, 2010 at 4:27 AM by JRoughan, version 2


No comments yet.