本文整理汇总了C#中ObjectRelationalMapper.Cascade方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectRelationalMapper.Cascade方法的具体用法?C# ObjectRelationalMapper.Cascade怎么用?C# ObjectRelationalMapper.Cascade使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectRelationalMapper
的用法示例。
在下文中一共展示了ObjectRelationalMapper.Cascade方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMapings
public static HbmMapping GetMapings(ObjectRelationalMapper orm)
{
domainEntities =
typeof(Entity).Assembly.GetTypes()
.Where(t => typeof(Entity).IsAssignableFrom(t) && !t.IsGenericType)
.ToList();
orm.Cascade<Claim, CPS.Domain.Action>(CascadeOn.None);
orm.Cascade<Branch, Claim>(CascadeOn.None);
orm.Cascade<Domain.Action,Document>(CascadeOn.All);
orm.Component<Address>();
orm.Component<Incident>();
orm.Component<ContactInfo>();
var patterns = new SafePropertyAccessorPack().Merge(new OneToOneRelationPack(orm))
.Merge(new BidirectionalManyToManyRelationPack(orm))
.Merge(new BidirectionalOneToManyRelationPack(orm))
.Merge(new DiscriminatorValueAsClassNamePack(orm))
.Merge(new CoolColumnsNamingPack(orm))
.Merge(new TablePerClassPack())
.Merge(new ListIndexAsPropertyPosColumnNameApplier())
.Merge(new PluralizedTablesPack(orm, new EnglishInflector()))
.Merge(new MsSQL2008DateTimeApplier());
var mapper = new Mapper(orm, patterns);
var mapping = mapper.CompileMappingFor(domainEntities);
Debug.WriteLine(mapping.AsString());
return mapping;
}
示例2: GetMapping
private static HbmMapping GetMapping()
{
var orm = new ObjectRelationalMapper();
var mapper = new Mapper(orm,
new CoolPatternsAppliersHolder(orm));
orm.TablePerClassHierarchy<Product>();
orm.TablePerClass<ActorRole>();
orm.Patterns.PoidStrategies.Add(
new GuidOptimizedPoidPattern());
orm.VersionProperty<Entity>(x => x.Version);
orm.NaturalId<Product>(p => p.Name);
orm.Cascade<Movie, ActorRole>(
Cascade.All | Cascade.DeleteOrphans);
mapper.AddPropertyPattern(mi =>
mi.GetPropertyOrFieldType() == typeof(Decimal) &&
mi.Name.Contains("Price"),
pm => pm.Type(NHibernateUtil.Currency));
mapper.AddPropertyPattern(mi =>
orm.IsRootEntity(mi.DeclaringType) &&
!"Description".Equals(mi.Name),
pm => pm.NotNullable(true));
mapper.Subclass<Movie>(cm =>
cm.List(movie => movie.Actors,
colm => colm.Index(
lim => lim.Column("ActorIndex")), m => { }));
var domainClasses = typeof(Entity).Assembly.GetTypes()
.Where(t => typeof(Entity).IsAssignableFrom(t));
return mapper.CompileMappingFor(domainClasses);
}
示例3: IntegrationWithObjectRelationalMapper
public void IntegrationWithObjectRelationalMapper()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<AEntity>();
orm.TablePerClass<BEntity>();
orm.ManyToOne<AEntity, BEntity>();
orm.Cascade<AEntity, BEntity>(Cascade.Persist | Cascade.Remove);
HbmMapping mapping = GetMapping(orm);
VerifyMappingWithCascade(mapping);
}
示例4: IntegrationWithObjectRelationalMapper
public void IntegrationWithObjectRelationalMapper()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Person>();
orm.TablePerClass<Animal>();
orm.ManyToMany<Person, Animal>();
orm.Cascade<Person, Animal>(Cascade.Persist);
HbmMapping mapping = GetMapping(orm);
VerifyMapping(mapping);
}
示例5: WhenCascadeIsTurnedOffInOrmShouldntApplyOnDeleteCascade
public void WhenCascadeIsTurnedOffInOrmShouldntApplyOnDeleteCascade()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass(new[] { typeof(UpAggregateRoot), typeof(DownAggregateRoot) });
orm.Cascade<UpAggregateRoot, DownAggregateRoot>(Cascade.None);
var mapper = new Mapper(orm);
var mapping = mapper.CompileMappingFor(new[] { typeof(UpAggregateRoot) });
HbmClass rc = mapping.RootClasses.Single();
var subNodes = (HbmBag)rc.Properties.Single(p => p.Name == "DownAggregateRoots");
subNodes.Key.ondelete.Should().Be(HbmOndelete.Noaction);
}
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:13,代码来源:BidirectionalOneToManyCascadeIntegrationTest.cs
示例6: WhenOrmCascadeIsAllThenApplyOndeleteCascade
public void WhenOrmCascadeIsAllThenApplyOndeleteCascade()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Parent>();
orm.TablePerClass<Child>();
orm.ManyToOne<Child, Parent>();
orm.Cascade<Parent, Child>(Cascade.All);
HbmMapping mapping = GetMapping(orm);
HbmClass rc = mapping.RootClasses.First(r => r.Name.Contains("Parent"));
var relation = rc.Properties.First(p => p.Name == "Children");
var collection = (HbmBag)relation;
collection.Key.ondelete.Should().Be(HbmOndelete.Cascade);
}
示例7: WhenOrmCascadeDoesNotIncludeDeleteNorDeleteOrhphanThenNotApplyOndeleteCascade
public void WhenOrmCascadeDoesNotIncludeDeleteNorDeleteOrhphanThenNotApplyOndeleteCascade()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Parent>();
orm.TablePerClass<Child>();
orm.ManyToOne<Child, Parent>();
orm.Cascade<Parent, Child>(Cascade.Persist | Cascade.ReAttach);
HbmMapping mapping = GetMapping(orm);
HbmClass rc = mapping.RootClasses.First(r => r.Name.Contains("Parent"));
var relation = rc.Properties.First(p => p.Name == "Children");
var collection = (HbmBag)relation;
collection.Key.ondelete.Should().Be(HbmOndelete.Noaction);
}
示例8: WhenExplicitRequiredByClassApplyCascade
public void WhenExplicitRequiredByClassApplyCascade()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Node>();
orm.Cascade<Node, Node>(Cascade.Persist);
HbmMapping mapping = GetMapping(orm);
HbmClass rc = mapping.RootClasses.Single();
var parent = (HbmManyToOne)rc.Properties.Single(p => p.Name == "Parent");
parent.cascade.Should().Contain("persist");
var subNodes = (HbmBag)rc.Properties.Single(p => p.Name == "Subnodes");
subNodes.cascade.Should().Contain("persist");
}
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:14,代码来源:BidirectionalOneToManyCascadeCircularIntegrationTest.cs
示例9: IntegrationWithObjectRelationalMapper
public void IntegrationWithObjectRelationalMapper()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<AEntity>();
orm.TablePerClass<BEntity>();
orm.OneToOne<AEntity, BEntity>();
orm.Cascade<AEntity, BEntity>(Cascade.Persist | Cascade.Remove);
HbmMapping mapping = GetMapping(orm);
// the default behaviour map an unidirectional one-to-one as a many-to-one (for NHibernate)
HbmClass rc = mapping.RootClasses.First(r => r.Name.Contains("AEntity"));
rc.Properties.Should().Have.Count.EqualTo(2);
rc.Properties.Select(p => p.Name).Should().Have.SameValuesAs("Name", "B");
var relation = rc.Properties.First(p => p.Name == "B");
((HbmManyToOne)relation).cascade.Should().Contain("persist").And.Contain("delete");
}
示例10: GetORM
private static ObjectRelationalMapper GetORM()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClassHierarchy<Product>();
orm.TablePerClass<ActorRole>();
orm.NaturalId<Product>(p => p.Name);
orm.Cascade<Movie, ActorRole>(
Cascade.All | Cascade.DeleteOrphans);
orm.Patterns.PoidStrategies
.Add(new GuidOptimizedPoidPattern());
orm.Patterns.Versions
.Add(new MyVersionPattern());
return orm;
}
示例11: WithExplicitCascadeToNone
public void WithExplicitCascadeToNone()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Parent>();
orm.TablePerClass<Child>();
orm.ManyToOne<Child, Parent>();
orm.Cascade<Parent, Child>(Cascade.None);
HbmMapping mapping = GetMapping(orm);
HbmClass rc = mapping.RootClasses.First(r => r.Name.Contains("Parent"));
var relation = rc.Properties.First(p => p.Name == "Children");
var collection = (HbmBag)relation;
collection.Cascade.Satisfy(c => string.IsNullOrEmpty(c));
}
示例12: WithExplicitCascadeToAll
public void WithExplicitCascadeToAll()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Parent>();
orm.TablePerClass<Child>();
orm.ManyToOne<Child, Parent>();
orm.Cascade<Parent, Child>(Cascade.All | Cascade.DeleteOrphans);
HbmMapping mapping = GetMapping(orm);
VerifyMapping(mapping);
}