/// <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); }
/// <summary> /// (optional) Specifies that this subclass is abstract /// </summary> public void Abstract() { attributes.Set("Abstract", Layer.UserSupplied, nextBool); nextBool = true; }
protected override void Set(string attribute, int layer, object value) { attributes.Set(attribute, layer, value); }
/// <summary> /// Specify the lazy-load behaviour /// </summary> public ComponentPart <T> LazyLoad() { attributes.Set("Lazy", Layer.UserSupplied, nextBool); nextBool = true; return(this); }
public IndexPart Type <TIndex>() { attributes.Set(x => x.Type, new TypeReference(typeof(TIndex))); return(this); }
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)); }
//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)); }
public CachePart ReadWrite() { attributes.Set(x => x.Usage, "read-write"); return(this); }
public IndexManyToManyPart Type <TIndex>() { attributes.Set(x => x.Class, new TypeReference(typeof(TIndex))); return(this); }
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)); }
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(); }
/// <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); }
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))); }
/// <summary> /// (optional) Specifies that this subclass is abstract /// </summary> public void Abstract() { attributes.Set(x => x.Abstract, nextBool); nextBool = true; }
public JoinedSubClassPart <TSubclass> Table(string tableName) { attributes.Set("TableName", Layer.UserSupplied, tableName); return(this); }
public IndexManyToManyPart Type <TIndex>() { attributes.Set("Class", Layer.UserSupplied, new TypeReference(typeof(TIndex))); return(this); }
/// <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); }
/// <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); }
/// <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)); }
/// <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); }
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(); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
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(); } }
/// <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(); }
/// <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); }