Exemple #1
0
        /// <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);
        }
Exemple #2
0
        /// <summary>
        /// Define a component (composite-element) to be used as the value of the dictionary.
        /// </summary>
        /// <param name="componentBuilder">Builder action</param>
        /// <returns>Builder</returns>
        public MapBuilder <TKey, TValue> Component(Action <CompositeElementBuilder <TValue> > componentBuilder)
        {
            var compositeElementMapping = new CompositeElementMapping();
            var builder = new CompositeElementBuilder <TValue>(compositeElementMapping, mapping.ContainingEntityType);

            componentBuilder(builder);

            mapping.CompositeElement = compositeElementMapping;
            mapping.Element          = null;
            mapping.Relationship     = null;

            return(this);
        }