Exemplo n.º 1
0
        public virtual DiscriminatorPart DiscriminateSubClassesOnColumn <TDiscriminator>(string columnName)
        {
            DiscriminatorPart discriminatorPart = new DiscriminatorPart(columnName, typeof(T), new Action <Type, ISubclassMappingProvider>(this.providers.Subclasses.Add), new TypeReference(typeof(TDiscriminator)));

            this.providers.Discriminator = (IDiscriminatorMappingProvider)discriminatorPart;
            return(discriminatorPart);
        }
Exemplo n.º 2
0
 protected SubClassPart(DiscriminatorPart parent, object discriminatorValue, MappingProviderStore providers)
     : base(providers)
 {
     this.parent             = parent;
     this.discriminatorValue = discriminatorValue;
     this.providers          = providers;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Specify that this entity should use a discriminator with it's subclasses.
        /// This is a mapping strategy called table-per-inheritance-hierarchy; where all
        /// subclasses are stored in the same table, differenciated by a discriminator
        /// column value.
        /// </summary>
        /// <typeparam name="TDiscriminator">Type of the discriminator column</typeparam>
        /// <param name="columnName">Discriminator column name</param>
        public virtual DiscriminatorPart DiscriminateSubClassesOnColumn <TDiscriminator>(string columnName)
        {
            var part = new DiscriminatorPart(columnName, typeof(T), subclasses.Add, new TypeReference(typeof(TDiscriminator)));

            discriminator = part;

            return(part);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Specify that this entity should use a discriminator with it's subclasses.
        /// This is a mapping strategy called table-per-inheritance-hierarchy; where all
        /// subclasses are stored in the same table, differenciated by a discriminator
        /// column value.
        /// </summary>
        /// <typeparam name="TDiscriminator">Type of the discriminator column</typeparam>
        /// <param name="columnName">Discriminator column name</param>
        /// <param name="baseClassDiscriminator">Default discriminator value</param>
        public virtual DiscriminatorPart DiscriminateSubClassesOnColumn <TDiscriminator>(string columnName, TDiscriminator baseClassDiscriminator)
        {
            var part = new DiscriminatorPart(columnName, typeof(T), subclasses.Add, new TypeReference(typeof(TDiscriminator)));

            discriminator = part;

            attributes.Set(x => x.DiscriminatorValue, baseClassDiscriminator);

            return(part);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Specify that this entity should use a discriminator with it's subclasses.
        /// This is a mapping strategy called table-per-inheritance-hierarchy; where all
        /// subclasses are stored in the same table, differenciated by a discriminator
        /// column value.
        /// </summary>
        /// <typeparam name="TDiscriminator">Type of the discriminator column</typeparam>
        /// <param name="columnName">Discriminator column name</param>
        /// <param name="baseClassDiscriminator">Default discriminator value</param>
        public DiscriminatorPart DiscriminateSubClassesOnColumn <TDiscriminator>(string columnName, TDiscriminator baseClassDiscriminator)
        {
            var part = new DiscriminatorPart(columnName, typeof(T), providers.Subclasses.Add, new TypeReference(typeof(TDiscriminator)));

            providers.Discriminator = part;

            attributes.Set("DiscriminatorValue", Layer.UserSupplied, baseClassDiscriminator);

            return(part);
        }
Exemplo n.º 6
0
        public virtual DiscriminatorPart DiscriminateSubClassesOnColumn <TDiscriminator>(string columnName, TDiscriminator baseClassDiscriminator)
        {
            DiscriminatorPart discriminatorPart = new DiscriminatorPart(columnName, typeof(T), new Action <Type, ISubclassMappingProvider>(this.providers.Subclasses.Add), new TypeReference(typeof(TDiscriminator)));

            this.providers.Discriminator = (IDiscriminatorMappingProvider)discriminatorPart;
            AttributeStore <ClassMapping> attributeStore      = this.attributes;
            ParameterExpression           parameterExpression = Expression.Parameter(typeof(ClassMapping), "x");
            // ISSUE: method reference
            Expression <Func <ClassMapping, object> > exp = Expression.Lambda <Func <ClassMapping, object> >((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(ClassMapping.get_DiscriminatorValue))), new ParameterExpression[1]
            {
                parameterExpression
            });
            // ISSUE: variable of a boxed type
            __Boxed <TDiscriminator> local = (object)baseClassDiscriminator;

            attributeStore.Set <object>(exp, (object)local);
            return(discriminatorPart);
        }
Exemplo n.º 7
0
 public SubClassPart(DiscriminatorPart parent, object discriminatorValue)
     : this(parent, discriminatorValue, new MappingProviderStore())
 {
 }
Exemplo n.º 8
0
 public SubClassPart(DiscriminatorPart parent, object discriminatorValue)
 {
     this.parent             = parent;
     this.discriminatorValue = discriminatorValue;
 }