public void ShouldWriteNestedCompositeElements() { var mapping = new CompositeElementMapping(); mapping.AddCompositeElement(new NestedCompositeElementMapping()); writer.VerifyXml(mapping) .Element("nested-composite-element").Exists(); }
public void ShouldWriteNestedCompositeElements() { var mapping = new CompositeElementMapping(); mapping.AddCompositeElement(new NestedCompositeElementMapping()); writer.VerifyXml(mapping) .Element("nested-composite-element").Exists(); }
/// <summary> /// Create a nested component mapping. /// </summary> /// <param name="property">Component property</param> /// <param name="nestedCompositeElementAction">Action for creating the component</param> /// <example> /// HasMany(x => x.Locations) /// .Component(c => /// { /// c.Map(x => x.Name); /// c.Component(x => x.Address, addr => /// { /// addr.Map(x => x.Street); /// addr.Map(x => x.PostCode); /// }); /// }); /// </example> public void Component <TChild>(Expression <Func <T, TChild> > property, Action <CompositeElementBuilder <TChild> > nestedCompositeElementAction) { var nestedMapping = new NestedCompositeElementMapping(); var nestedCompositeElement = new CompositeElementBuilder <TChild>(nestedMapping, mapping.ContainingEntityType, property.ToMember()); nestedCompositeElementAction(nestedCompositeElement); mapping.AddCompositeElement(nestedMapping); }
public void ShouldWriteNestedCompositeElementName() { var mapping = new CompositeElementMapping(); mapping.AddCompositeElement(new NestedCompositeElementMapping { Name = "testName"}); writer.VerifyXml(mapping) .Element("nested-composite-element") .HasAttribute("name", "testName"); }
public void ShouldWriteNestedCompositeElementName() { var mapping = new CompositeElementMapping(); var nestedCompositeElementMapping = new NestedCompositeElementMapping(); nestedCompositeElementMapping.Set(x => x.Name, Layer.Defaults, "testName"); mapping.AddCompositeElement(nestedCompositeElementMapping); writer.VerifyXml(mapping) .Element("nested-composite-element") .HasAttribute("name", "testName"); }
public void ShouldWriteNestedCompositeElementName() { var mapping = new CompositeElementMapping(); var nestedCompositeElementMapping = new NestedCompositeElementMapping(); nestedCompositeElementMapping.Set(x => x.Name, Layer.Defaults, "testName"); mapping.AddCompositeElement(nestedCompositeElementMapping); writer.VerifyXml(mapping) .Element("nested-composite-element") .HasAttribute("name", "testName"); }
public void ShouldWriteNestedCompositeElementName() { var mapping = new CompositeElementMapping(); mapping.AddCompositeElement(new NestedCompositeElementMapping { Name = "testName" }); writer.VerifyXml(mapping) .Element("nested-composite-element") .HasAttribute("name", "testName"); }
void PopulateMapping(CompositeElementMapping mapping) { mapping.ContainingEntityType = entity; mapping.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(T))); foreach (var property in properties) { mapping.AddProperty(property.GetPropertyMapping()); } foreach (var reference in references) { mapping.AddReference(reference.GetManyToOneMapping()); } foreach (var component in components) { mapping.AddCompositeElement(component.GetCompositeElementMapping()); } }
void PopulateMapping(CompositeElementMapping mapping) { mapping.ContainingEntityType = entity; if (!mapping.IsSpecified("Class")) { mapping.Class = new TypeReference(typeof(T)); } foreach (var property in properties) { mapping.AddProperty(property.GetPropertyMapping()); } foreach (var reference in references) { mapping.AddReference(reference.GetManyToOneMapping()); } foreach (var component in components) { mapping.AddCompositeElement(component.GetCompositeElementMapping()); } }