/// <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); }
NestedCompositeElementMapping INestedCompositeElementMappingProvider.GetCompositeElementMapping() { var mapping = new NestedCompositeElementMapping(attributes.Clone()); mapping.Set(x => x.Name, Layer.Defaults, member.Name); PopulateMapping(mapping); return(mapping); }
NestedCompositeElementMapping INestedCompositeElementMappingProvider.GetCompositeElementMapping() { var mapping = new NestedCompositeElementMapping(attributes.CloneInner()); mapping.Name = member.Name; PopulateMapping(mapping); return(mapping); }
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"); }