Ejemplo n.º 1
0
 /// <summary>
 /// Sets the precision for decimals
 /// </summary>
 /// <param name="precision">Decimal precision</param>
 public DiscriminatorPart Precision(int precision)
 {
     columnAttributes.Set("Precision", Layer.UserSupplied, precision);
     return(this);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// (optional) Specifies that this subclass is abstract
 /// </summary>
 public void Abstract()
 {
     attributes.Set("Abstract", Layer.UserSupplied, nextBool);
     nextBool = true;
 }
Ejemplo n.º 3
0
 protected override void Set(string attribute, int layer, object value)
 {
     attributes.Set(attribute, layer, value);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Specify the lazy-load behaviour
 /// </summary>
 public ComponentPart <T> LazyLoad()
 {
     attributes.Set("Lazy", Layer.UserSupplied, nextBool);
     nextBool = true;
     return(this);
 }
Ejemplo n.º 5
0
 public IndexPart Type <TIndex>()
 {
     attributes.Set(x => x.Type, new TypeReference(typeof(TIndex)));
     return(this);
 }
Ejemplo n.º 6
0
 public AnyPart(Type entity, Member property)
 {
     this.entity   = entity;
     this.property = property;
     access        = new AccessStrategyBuilder <AnyPart <T> >(this, value => attributes.Set(x => x.Access, value));
     cascade       = new CascadeExpression <AnyPart <T> >(this, value => attributes.Set(x => x.Cascade, value));
 }
Ejemplo n.º 7
0
        //PROTOTYPE1: ADDED

        public PropertyPart(Member member, Type parentType)
        {
            columns   = new ColumnMappingCollection <PropertyPart>(this);
            access    = new AccessStrategyBuilder <PropertyPart>(this, value => attributes.Set("Access", Layer.UserSupplied, value));
            generated = new PropertyGeneratedBuilder(this, value => attributes.Set("Generated", Layer.UserSupplied, value));

            this.member     = member;
            this.parentType = parentType;

            SetDefaultAccess();
        }
 public CompositeIdentityPart()
 {
     access = new AccessStrategyBuilder <CompositeIdentityPart <T> >(this, value => attributes.Set("Access", Layer.UserSupplied, value));
 }
Ejemplo n.º 9
0
 public CachePart ReadWrite()
 {
     attributes.Set(x => x.Usage, "read-write");
     return(this);
 }
Ejemplo n.º 10
0
 public IndexManyToManyPart Type <TIndex>()
 {
     attributes.Set(x => x.Class, new TypeReference(typeof(TIndex)));
     return(this);
 }
Ejemplo n.º 11
0
 public ClassMap()
 {
     optimisticLock = new OptimisticLockBuilder <ClassMap <T> >(this, value => attributes.Set(x => x.OptimisticLock, value));
     polymorphism   = new PolymorphismBuilder <ClassMap <T> >(this, value => attributes.Set(x => x.Polymorphism, value));
     schemaAction   = new SchemaActionBuilder <ClassMap <T> >(this, value => attributes.Set(x => x.SchemaAction, value));
 }
Ejemplo n.º 12
0
        public AnyPart(Type entity, Member member)
        {
            this.entity = entity;
            this.member = member;
            access      = new AccessStrategyBuilder <AnyPart <T> >(this, value => attributes.Set("Access", Layer.UserSupplied, value));
            cascade     = new CascadeExpression <AnyPart <T> >(this, value =>
            {
                var current = attributes.Get("Cascade") as string;
                attributes.Set("Cascade", Layer.UserSupplied, current == null ? value : string.Format("{0},{1}", current, value));
            });

            SetDefaultAccess();
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Specifies an entity-name.
 /// </summary>
 /// <remarks>See http://nhforge.org/blogs/nhibernate/archive/2008/10/21/entity-name-in-action-a-strongly-typed-entity.aspx</remarks>
 public T EntityName(string entityName)
 {
     relationshipAttributes.Set(x => x.EntityName, entityName);
     return((T)this);
 }
Ejemplo n.º 14
0
        protected ToManyBase(Type entity, Member member, Type type)
        {
            this.entity = entity;
            this.member = member;
            AsBag();
            access         = new AccessStrategyBuilder <T>((T)this, value => collectionAttributes.Set(x => x.Access, value));
            fetch          = new FetchTypeExpression <T>((T)this, value => collectionAttributes.Set(x => x.Fetch, value));
            optimisticLock = new OptimisticLockBuilder <T>((T)this, value => collectionAttributes.Set(x => x.OptimisticLock, value));
            cascade        = new CollectionCascadeExpression <T>((T)this, value => collectionAttributes.Set(x => x.Cascade, value));

            SetDefaultCollectionType(type);
            SetCustomCollectionType(type);
            Cache = new CachePart(entity);

            collectionAttributes.SetDefault(x => x.Name, member.Name);
            relationshipAttributes.SetDefault(x => x.Class, new TypeReference(typeof(TChild)));
        }
Ejemplo n.º 15
0
 /// <summary>
 /// (optional) Specifies that this subclass is abstract
 /// </summary>
 public void Abstract()
 {
     attributes.Set(x => x.Abstract, nextBool);
     nextBool = true;
 }
Ejemplo n.º 16
0
 public JoinedSubClassPart <TSubclass> Table(string tableName)
 {
     attributes.Set("TableName", Layer.UserSupplied, tableName);
     return(this);
 }
Ejemplo n.º 17
0
 public IndexManyToManyPart Type <TIndex>()
 {
     attributes.Set("Class", Layer.UserSupplied, new TypeReference(typeof(TIndex)));
     return(this);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Sets whether this subclass is lazy loaded
 /// </summary>
 /// <returns></returns>
 public SubClassPart <TSubclass> LazyLoad()
 {
     attributes.Set("Lazy", Layer.UserSupplied, nextBool);
     nextBool = true;
     return(this);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Specify the element type
 /// </summary>
 /// <typeparam name="TElement">Element type</typeparam>
 public ElementPart Type <TElement>()
 {
     attributes.Set(x => x.Type, new TypeReference(typeof(TElement)));
     return(this);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Specify the column length
 /// </summary>
 /// <param name="length">Column length</param>
 public PropertyBuilder Length(int length)
 {
     columnAttributes.Set(x => x.Length, length);
     return(this);
 }
 private DynamicComponentPart(Type entity, string propertyName, AttributeStore underlyingStore)
     : base(underlyingStore, propertyName)
 {
     this.entity = entity;
     attributes  = new AttributeStore <ComponentMapping>(underlyingStore);
     access      = new AccessStrategyBuilder <DynamicComponentPart <T> >(this, value => attributes.Set(x => x.Access, value));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Specifies that this id is read-only
 /// </summary>
 /// <remarks>This is the same as setting the mutable attribute to false</remarks>
 public NaturalIdPart <T> ReadOnly()
 {
     attributes.Set("Mutable", Layer.UserSupplied, !nextBool);
     nextBool = true;
     return(this);
 }
Ejemplo n.º 23
0
        public ManyToOnePart(Type entity, Member member)
        {
            this.entity = entity;
            this.member = member;
            access      = new AccessStrategyBuilder <ManyToOnePart <TOther> >(this, value => attributes.Set("Access", Layer.UserSupplied, value));
            fetch       = new FetchTypeExpression <ManyToOnePart <TOther> >(this, value => attributes.Set("Fetch", Layer.UserSupplied, value));
            cascade     = new CascadeExpression <ManyToOnePart <TOther> >(this, value => attributes.Set("Cascade", Layer.UserSupplied, value));
            notFound    = new NotFoundExpression <ManyToOnePart <TOther> >(this, value => attributes.Set("NotFound", Layer.UserSupplied, value));

            SetDefaultAccess();
        }
Ejemplo n.º 24
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);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Sets whether this relationship is unique
 /// </summary>
 /// <example>
 /// Unique();
 /// Not.Unique();
 /// </example>
 public ManyToOnePart <TOther> Unique()
 {
     columnAttributes.Set("Unique", Layer.UserSupplied, nextBool);
     nextBool = true;
     return(this);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Force NHibernate to always select using the discriminator value, even when selecting all subclasses. This
 /// can be useful when your table contains more discriminator values than you have classes (legacy).
 /// </summary>
 /// <remarks>Sets the "force" attribute.</remarks>
 public DiscriminatorPart AlwaysSelectWithValue()
 {
     attributes.Set("Force", Layer.UserSupplied, nextBool);
     nextBool = true;
     return(this);
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Specify the element type
 /// </summary>
 /// <typeparam name="TElement">Element type</typeparam>
 public ElementPart Type <TElement>()
 {
     attributes.Set("Type", Layer.UserSupplied, new TypeReference(typeof(TElement)));
     return(this);
 }
Ejemplo n.º 28
0
        protected ComponentPartBase(AttributeStore attributes, Member member, MappingProviderStore providers)
            : base(providers)
        {
            this.attributes = attributes;
            access          = new AccessStrategyBuilder <TBuilder>((TBuilder)this, value => attributes.Set("Access", Layer.UserSupplied, value));
            this.member     = member;
            this.providers  = providers;

            if (member != null)
            {
                SetDefaultAccess();
            }
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Specify the element column length
 /// </summary>
 /// <param name="length">Column length</param>
 public ElementPart Length(int length)
 {
     columnAttributes.Set("Length", Layer.UserSupplied, length);
     return(this);
 }
 public void CreateNewAttributeStore()
 {
     var store = new AttributeStore();
     var value = new object();
     store.Set("name1", value, new NameValueMapAttribute { Name = "A.B.C" });
     store.Get("name1").Layer.ShouldEqual(3);
     store.Get("name1").Value.ShouldEqual(value);
     store.Set("name1", value, new NameValueMapAttribute { Name = "A.B" });
     store.Get("name1").Layer.ShouldEqual(2);
     store.Get("name1").Value.ShouldEqual(value);
     store.Equals(store.Clone()).ShouldBeTrue();
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Sets whether this relationship is unique
 /// </summary>
 /// <example>
 /// Unique();
 /// Not.Unique();
 /// </example>
 public ManyToOneBuilder <TOther> Unique()
 {
     columnAttributes.Set(x => x.Unique, nextBool);
     nextBool = true;
     return(this);
 }