void ContentDetailCustomization(IClassMapper <ContentDetail> ca) { ca.Table(tablePrefix + "Detail"); ca.Lazy(false); ca.Cache(cm => { cm.Usage(CacheUsage.NonstrictReadWrite); cm.Region(cacheRegion); }); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.ManyToOne(x => x.EnclosingItem, cm => { cm.Column("ItemID"); cm.NotNullable(true); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); }); ca.ManyToOne(x => x.EnclosingCollection, cm => { cm.Column("DetailCollectionID"); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); }); ca.Property(x => x.ValueTypeKey, cm => { cm.Column("Type"); cm.Length(10); }); ca.Property(x => x.Name, cm => { cm.Length(50); }); ca.Property(x => x.Meta, cm => { cm.Type(NHibernateUtil.StringClob); cm.Length(stringLength); }); ca.Property(x => x.BoolValue, cm => { }); ca.Property(x => x.DateTimeValue, cm => { }); ca.Property(x => x.IntValue, cm => { }); ca.Component(x => x.LinkedItem, cm => { cm.Property(cr => cr.ID, pm => pm.Column("LinkValue")); }); //ca.ManyToOne(x => x.LinkedItem, cm => { cm.Column("LinkValue"); cm.NotFound(NotFoundMode.Ignore); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); cm.Cascade(Cascade.None); }); ca.Property(x => x.DoubleValue, cm => { }); // if you are using Oracle10g and get // ORA-01461: can bind a LONG value only for insert into a LONG column // use the following line instead of the the later one (NOTICE both apply to the same property) // ca.Property(x => x.StringValue, cm => { cm.Type(NHibernateUtil.AnsiString); cm.Length(stringLength); }); ca.Property(x => x.StringValue, cm => { cm.Type(NHibernateUtil.StringClob); cm.Length(stringLength); }); ca.Property(x => x.ObjectValue, cm => { cm.Column("Value"); cm.Type(NHibernateUtil.Serializable); cm.Length(ConfigurationBuilder.BlobLength); }); }
void AuthorizedRoleCustomization(IClassMapper <AuthorizedRole> ca) { ca.Table(tablePrefix + "AllowedRole"); ca.Lazy(false); ca.Cache(cm => { cm.Usage(CacheUsage.NonstrictReadWrite); cm.Region(cacheRegion); }); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.ManyToOne(x => x.EnclosingItem, cm => { cm.Column("ItemID"); cm.NotNullable(true); }); ca.Property(x => x.Role, cm => { cm.Length(50); cm.NotNullable(true); }); }
void FileSystemChunkCustomization(IClassMapper <FileSystemChunk> ca) { ca.Table(tablePrefix + "FSChunk"); ca.Lazy(false); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.ManyToOne(x => x.BelongsTo, m => { m.Column("FileID"); }); ca.Property(x => x.Offset, cm => { }); ca.Property(cm => cm.Data, cm => { cm.Type(NHibernateUtil.BinaryBlob); cm.Length(ConfigurationBuilder.BlobLength); cm.Lazy(false); }); }
void FileSystemChunkCustomization(IClassMapper<FileSystemChunk> ca) { ca.Table(tablePrefix + "FSChunk"); ca.Lazy(false); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.ManyToOne(x => x.BelongsTo, m => { m.Column("FileID"); }); ca.Property(x => x.Offset, cm => { }); ca.Property(cm => cm.Data, cm => { cm.Type(NHibernateUtil.BinaryBlob); cm.Length(ConfigurationBuilder.BlobLength); cm.Lazy(false); }); }
void ContentDetailCustomization(IClassMapper <ContentDetail> ca) { ca.Table(tablePrefix + "Detail"); ca.Lazy(false); ca.Cache(cm => { cm.Usage(CacheUsage.NonstrictReadWrite); }); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.ManyToOne(x => x.EnclosingItem, cm => { cm.Column("ItemID"); cm.NotNullable(true); cm.Fetch(FetchKind.Select); }); ca.ManyToOne(x => x.EnclosingCollection, cm => { cm.Column("DetailCollectionID"); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); }); ca.Property(x => x.ValueTypeKey, cm => { cm.Column("Type"); cm.Length(10); }); ca.Property(x => x.Name, cm => { cm.Length(50); }); ca.Property(x => x.BoolValue, cm => { }); ca.Property(x => x.DateTimeValue, cm => { }); ca.Property(x => x.IntValue, cm => { }); ca.ManyToOne(x => x.LinkedItem, cm => { cm.Column("LinkValue"); cm.Lazy(LazyRelation.Proxy); cm.Cascade(Cascade.None); }); ca.Property(x => x.DoubleValue, cm => { }); ca.Property(x => x.StringValue, cm => { cm.Type(NHibernateUtil.StringClob); cm.Length(stringLength); }); ca.Property(x => x.ObjectValue, cm => { cm.Column("Value"); cm.Type(NHibernateUtil.Serializable); cm.Length(2147483647); }); }
void ContentDetailCustomization(IClassMapper <ContentDetail> ca) { ca.Table(tablePrefix + "Detail"); ca.Lazy(false); ca.Cache(cm => { cm.Usage(CacheUsage.NonstrictReadWrite); cm.Region(cacheRegion); }); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.ManyToOne(x => x.EnclosingItem, cm => { cm.Column("ItemID"); cm.NotNullable(true); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); }); ca.ManyToOne(x => x.EnclosingCollection, cm => { cm.Column("DetailCollectionID"); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); }); ca.Property(x => x.ValueTypeKey, cm => { cm.Column("Type"); cm.Length(10); }); ca.Property(x => x.Name, cm => { cm.Length(50); }); ca.Property(x => x.Meta, cm => { cm.Type(GetStringClobType()); cm.Length(stringLength); }); ca.Property(x => x.BoolValue, cm => { }); ca.Property(x => x.DateTimeValue, cm => { }); ca.Property(x => x.IntValue, cm => { }); ca.Component(x => x.LinkedItem, cm => { cm.Property(cr => cr.ID, pm => pm.Column("LinkValue")); }); //ca.ManyToOne(x => x.LinkedItem, cm => { cm.Column("LinkValue"); cm.NotFound(NotFoundMode.Ignore); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); cm.Cascade(Cascade.None); }); ca.Property(x => x.DoubleValue, cm => { }); ca.Property(x => x.StringValue, cm => { cm.Type(GetStringClobType()); cm.Length(stringLength); }); ca.Property(x => x.ObjectValue, cm => { cm.Column("Value"); cm.Type(NHibernateUtil.Serializable); cm.Length(ConfigurationBuilder.BlobLength); }); }
void DetailCollectionCustomization(IClassMapper <DetailCollection> ca) { ca.Table(tablePrefix + "DetailCollection"); ca.Lazy(false); ca.Cache(cm => { cm.Usage(CacheUsage.NonstrictReadWrite); cm.Region(cacheRegion); }); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.ManyToOne(x => x.EnclosingItem, cm => { cm.Column("ItemID"); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); }); ca.Property(x => x.Name, cm => { cm.Length(50); cm.NotNullable(true); }); ca.Bag(x => x.Details, cm => { cm.Key(k => k.Column("DetailCollectionID")); cm.Inverse(true); cm.Cascade(Cascade.All | Cascade.DeleteOrphans); cm.Lazy(CollectionLazy.Lazy); cm.Fetch(CollectionFetchMode.Select); cm.Cache(m => { m.Usage(CacheUsage.NonstrictReadWrite); m.Region(cacheRegion); }); }, cr => cr.OneToMany()); }
void AuthorizedRoleCustomization(IClassMapper<AuthorizedRole> ca) { ca.Table(tablePrefix + "AllowedRole"); ca.Lazy(false); ca.Cache(cm => { cm.Usage(CacheUsage.NonstrictReadWrite); cm.Region(cacheRegion); }); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.ManyToOne(x => x.EnclosingItem, cm => { cm.Column("ItemID"); cm.NotNullable(true); }); ca.Property(x => x.Role, cm => { cm.Length(50); cm.NotNullable(true); }); }
void DetailCollectionCustomization(IClassMapper<DetailCollection> ca) { ca.Table(tablePrefix + "DetailCollection"); ca.Lazy(false); ca.Cache(cm => { cm.Usage(CacheUsage.NonstrictReadWrite); cm.Region(cacheRegion); }); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.ManyToOne(x => x.EnclosingItem, cm => { cm.Column("ItemID"); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); }); ca.Property(x => x.Name, cm => { cm.Length(50); cm.NotNullable(true); }); ca.Bag(x => x.Details, cm => { cm.Key(k => k.Column("DetailCollectionID")); cm.Inverse(true); cm.Cascade(Cascade.All | Cascade.DeleteOrphans); cm.Lazy(CollectionLazy.Lazy); cm.Fetch(CollectionFetchMode.Select); cm.Cache(m => { m.Usage(CacheUsage.NonstrictReadWrite); m.Region(cacheRegion); }); }, cr => cr.OneToMany()); }
void ContentDetailCustomization(IClassMapper<ContentDetail> ca) { ca.Table(tablePrefix + "Detail"); ca.Lazy(false); ca.Cache(cm => { cm.Usage(CacheUsage.NonstrictReadWrite); cm.Region(cacheRegion); }); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.ManyToOne(x => x.EnclosingItem, cm => { cm.Column("ItemID"); cm.NotNullable(true); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); }); ca.ManyToOne(x => x.EnclosingCollection, cm => { cm.Column("DetailCollectionID"); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); }); ca.Property(x => x.ValueTypeKey, cm => { cm.Column("Type"); cm.Length(10); }); ca.Property(x => x.Name, cm => { cm.Length(50); }); ca.Property(x => x.Meta, cm => { cm.Type(NHibernateUtil.StringClob); cm.Length(stringLength); }); ca.Property(x => x.BoolValue, cm => { }); ca.Property(x => x.DateTimeValue, cm => { }); ca.Property(x => x.IntValue, cm => { }); ca.Component(x => x.LinkedItem, cm => { cm.Property(cr => cr.ID, pm => pm.Column("LinkValue")); }); //ca.ManyToOne(x => x.LinkedItem, cm => { cm.Column("LinkValue"); cm.NotFound(NotFoundMode.Ignore); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); cm.Cascade(Cascade.None); }); ca.Property(x => x.DoubleValue, cm => { }); // if you are using Oracle10g and get // ORA-01461: can bind a LONG value only for insert into a LONG column // use the following line instead of the the later one (NOTICE both apply to the same property) // ca.Property(x => x.StringValue, cm => { cm.Type(NHibernateUtil.AnsiString); cm.Length(stringLength); }); ca.Property(x => x.StringValue, cm => { cm.Type(NHibernateUtil.StringClob); cm.Length(stringLength); }); ca.Property(x => x.ObjectValue, cm => { cm.Column("Value"); cm.Type(NHibernateUtil.Serializable); cm.Length(ConfigurationBuilder.BlobLength); }); }
void ContentItemCustomization(IClassMapper<ContentItem> ca) { ca.Table(tablePrefix + "Item"); ca.Lazy(false); ca.Cache(cm => { cm.Usage(CacheUsage.NonstrictReadWrite); cm.Region(cacheRegion); }); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.Discriminator(cm => { cm.Column("Type"); cm.Type(NHibernateUtil.String); }); ca.Property(x => x.Created, cm => { }); ca.Property(x => x.Published, cm => { }); ca.Property(x => x.Updated, cm => { }); ca.Property(x => x.Expires, cm => { }); ca.Property(x => x.Name, cm => { cm.Length(250); }); ca.Property(x => x.ZoneName, cm => { cm.Length(50); }); ca.Property(x => x.TemplateKey, cm => { cm.Length(50); }); ca.Property(x => x.TranslationKey, cm => { }); ca.Property(x => x.Title, cm => { cm.Length(250); }); ca.Property(x => x.SortOrder, cm => { }); ca.Property(x => x.Visible, cm => { }); ca.Property(x => x.SavedBy, cm => { cm.Length(50); }); ca.Property(x => x.State, cm => { }); ca.Property(x => x.ChildState, cm => { }); ca.Property(x => x.AncestralTrail, cm => { cm.Length(100); }); ca.Property(x => x.VersionIndex, cm => { }); ca.Property(x => x.AlteredPermissions, cm => { }); //ca.ManyToOne(x => x.VersionOf, cm => { cm.Column("VersionOfID"); cm.Lazy(LazyRelation.Proxy); cm.Fetch(FetchKind.Select); }); //ca.Property(x => x.VersionOf, cm => //{ // cm.Column("VersionOfID"); // cm.Type<ContentRelationFactory>(); //}); ca.Component(x => x.VersionOf, cm => { cm.Property(cr => cr.ID, pm => pm.Column("VersionOfID")); }); ca.ManyToOne(x => x.Parent, cm => { cm.Column("ParentID"); cm.Lazy(LazyRelation.Proxy); cm.Fetch(FetchKind.Select); }); ca.Bag(x => x.Children, cm => { cm.Key(k => k.Column("ParentID")); cm.Inverse(true); cm.Type<ContentItemListFactory<ContentItem>>(); cm.Cascade(childrenCascade); cm.OrderBy(ci => ci.SortOrder); cm.Lazy(childrenLaziness); if (childrenBatch) cm.BatchSize(batchSize ?? 10); cm.Cache(m => { m.Usage(CacheUsage.NonstrictReadWrite); m.Region(cacheRegion); }); }, cr => cr.OneToMany()); ca.Bag(x => x.Details, cm => { cm.Key(k => k.Column("ItemID")); cm.Inverse(true); cm.Type<ContentListFactory<ContentDetail>>(); cm.Cascade(Cascade.All | Cascade.DeleteOrphans); cm.Fetch(CollectionFetchMode.Select); cm.Lazy(CollectionLazy.Lazy); cm.BatchSize(batchSize ?? 10); cm.Cache(m => { m.Usage(CacheUsage.NonstrictReadWrite); m.Region(cacheRegion); }); cm.Where("DetailCollectionID IS NULL"); }, cr => cr.OneToMany()); ca.Bag(x => x.DetailCollections, cm => { cm.Key(k => k.Column("ItemID")); cm.Inverse(true); cm.Type<ContentListFactory<DetailCollection>>(); cm.Cascade(Cascade.All | Cascade.DeleteOrphans); cm.Fetch(CollectionFetchMode.Select); cm.Lazy(CollectionLazy.Lazy); cm.BatchSize(batchSize ?? 10); cm.Cache(m => { m.Usage(CacheUsage.NonstrictReadWrite); m.Region(cacheRegion); }); }, cr => cr.OneToMany()); ca.Bag(x => x.AuthorizedRoles, cm => { cm.Key(k => k.Column("ItemID")); cm.Inverse(true); cm.Cascade(Cascade.All | Cascade.DeleteOrphans); cm.Fetch(CollectionFetchMode.Select); cm.Lazy(CollectionLazy.Lazy); cm.BatchSize(batchSize ?? 25); cm.Cache(m => { m.Usage(CacheUsage.NonstrictReadWrite); m.Region(cacheRegion); }); }, cr => cr.OneToMany()); }
void ContentItemCustomization(IClassMapper <ContentItem> ca) { ca.Table(tablePrefix + "Item"); ca.Lazy(false); ca.Cache(cm => { cm.Usage(CacheUsage.NonstrictReadWrite); cm.Region(cacheRegion); }); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.Discriminator(cm => { cm.Column("Type"); cm.Type(NHibernateUtil.String); }); ca.Property(x => x.Created, cm => { }); ca.Property(x => x.Published, cm => { }); ca.Property(x => x.Updated, cm => { }); ca.Property(x => x.Expires, cm => { }); ca.Property(x => x.Name, cm => { cm.Length(250); }); ca.Property(x => x.ZoneName, cm => { cm.Length(50); }); ca.Property(x => x.TemplateKey, cm => { cm.Length(50); }); ca.Property(x => x.TranslationKey, cm => { }); ca.Property(x => x.Title, cm => { cm.Length(250); }); ca.Property(x => x.SortOrder, cm => { }); ca.Property(x => x.Visible, cm => { }); ca.Property(x => x.SavedBy, cm => { cm.Length(50); }); ca.Property(x => x.State, cm => { }); ca.Property(x => x.ChildState, cm => { }); ca.Property(x => x.AncestralTrail, cm => { cm.Length(100); }); ca.Property(x => x.VersionIndex, cm => { }); ca.Property(x => x.AlteredPermissions, cm => { }); //ca.ManyToOne(x => x.VersionOf, cm => { cm.Column("VersionOfID"); cm.Lazy(LazyRelation.Proxy); cm.Fetch(FetchKind.Select); }); //ca.Property(x => x.VersionOf, cm => //{ // cm.Column("VersionOfID"); // cm.Type<ContentRelationFactory>(); //}); ca.Component(x => x.VersionOf, cm => { cm.Property(cr => cr.ID, pm => pm.Column("VersionOfID")); }); ca.ManyToOne(x => x.Parent, cm => { cm.Column("ParentID"); cm.Lazy(LazyRelation.Proxy); cm.Fetch(FetchKind.Select); }); ca.Bag(x => x.Children, cm => { cm.Key(k => k.Column("ParentID")); cm.Inverse(true); cm.Type <ContentItemListFactory <ContentItem> >(); cm.Cascade(childrenCascade); cm.OrderBy(ci => ci.SortOrder); cm.Lazy(childrenLaziness); if (childrenBatch) { cm.BatchSize(batchSize ?? 10); } cm.Cache(m => { m.Usage(CacheUsage.NonstrictReadWrite); m.Region(cacheRegion); }); }, cr => cr.OneToMany()); ca.Bag(x => x.Details, cm => { cm.Key(k => k.Column("ItemID")); cm.Inverse(true); cm.Type <ContentListFactory <ContentDetail> >(); cm.Cascade(Cascade.All | Cascade.DeleteOrphans); cm.Fetch(CollectionFetchMode.Select); cm.Lazy(CollectionLazy.Lazy); cm.BatchSize(batchSize ?? 10); cm.Cache(m => { m.Usage(CacheUsage.NonstrictReadWrite); m.Region(cacheRegion); }); cm.Where("DetailCollectionID IS NULL"); }, cr => cr.OneToMany()); ca.Bag(x => x.DetailCollections, cm => { cm.Key(k => k.Column("ItemID")); cm.Inverse(true); cm.Type <DetailCollectionFactory>(); cm.Cascade(Cascade.All | Cascade.DeleteOrphans); cm.Fetch(CollectionFetchMode.Select); cm.Lazy(CollectionLazy.Lazy); cm.BatchSize(batchSize ?? 10); cm.Cache(m => { m.Usage(CacheUsage.NonstrictReadWrite); m.Region(cacheRegion); }); }, cr => cr.OneToMany()); ca.Bag(x => x.AuthorizedRoles, cm => { cm.Key(k => k.Column("ItemID")); cm.Inverse(true); cm.Cascade(Cascade.All | Cascade.DeleteOrphans); cm.Fetch(CollectionFetchMode.Select); cm.Lazy(CollectionLazy.Lazy); cm.BatchSize(batchSize ?? 25); cm.Cache(m => { m.Usage(CacheUsage.NonstrictReadWrite); m.Region(cacheRegion); }); }, cr => cr.OneToMany()); }
void ContentDetailCustomization(IClassMapper<ContentDetail> ca) { ca.Table(tablePrefix + "Detail"); ca.Lazy(false); ca.Cache(cm => { cm.Usage(CacheUsage.NonstrictReadWrite); }); ca.Id(x => x.ID, cm => { cm.Generator(Generators.Native); }); ca.ManyToOne(x => x.EnclosingItem, cm => { cm.Column("ItemID"); cm.NotNullable(true); cm.Fetch(FetchKind.Select); }); ca.ManyToOne(x => x.EnclosingCollection, cm => { cm.Column("DetailCollectionID"); cm.Fetch(FetchKind.Select); cm.Lazy(LazyRelation.Proxy); }); ca.Property(x => x.ValueTypeKey, cm => { cm.Column("Type"); cm.Length(10); }); ca.Property(x => x.Name, cm => { cm.Length(50); }); ca.Property(x => x.BoolValue, cm => { }); ca.Property(x => x.DateTimeValue, cm => { }); ca.Property(x => x.IntValue, cm => { }); ca.ManyToOne(x => x.LinkedItem, cm => { cm.Column("LinkValue"); cm.Lazy(LazyRelation.Proxy); cm.Cascade(Cascade.None); }); ca.Property(x => x.DoubleValue, cm => { }); ca.Property(x => x.StringValue, cm => { cm.Type(NHibernateUtil.StringClob); cm.Length(stringLength); }); ca.Property(x => x.ObjectValue, cm => { cm.Column("Value"); cm.Type(NHibernateUtil.Serializable); cm.Length(2147483647); }); }
/// <summary> /// 代理执行Many - one方法 /// </summary> /// <typeparam name="X">Entity类型泛型</typeparam> /// <typeparam name="T">参数类型泛型</typeparam> /// <param name="inputValue">输入的Mapper</param> /// <param name="inputProperty">输入的表达式参数</param> private static void ManyToOne <X, T>(IClassMapper <X> inputValue, Expression <Func <X, T> > inputProperty) where X : BaseEntity where T : BaseEntity { inputValue.ManyToOne <T>(inputProperty); }