I find we can specify the "default-cascade" attribute of the element. But how can I do it in Fluent NHibernate? And I don't want to use AutoMapping.

有帮助吗?

解决方案

The detailed description could be found here: https://github.com/jagregory/fluent-nhibernate/wiki/Conventions. An extract:

There are some situations that are so obvious that they just cried out for a simple shortcut that can be applied globally to your project:

Table.Is(x => x.EntityType.Name + "Table")
...
DefaultCascade.All()
...

And this way we can use it:

Fluently.Configure()
  .Database(/* database config */)
  .Mappings(m =>
  {
    m.FluentMappings
      .AddFromAssemblyOf<Entity>()
      .Conventions.Add(DefaultCascade.All());
  })

Also check this, to get some idea how to implement own Conventions Fluent NHibernate automapping and cascading

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top