Cascade Saves with Fluent NHibernate AutoMapping - Old Answer Still Valid?

前端 未结 3 447
离开以前
离开以前 2020-12-29 14:15

I want to do exactly what this question asks: Cascade Saves with Fluent NHibernate AutoMapping

Using Fluent Nhibernate Mappings to turn on \"cascade\" globally once

3条回答
  •  长发绾君心
    2020-12-29 14:37

    The easiest way I've found to do this for a whole project is to use DefaultCascade:

    .Conventions.Add( DefaultCascade.All() );     
    

    Go to "The Simplest Conventions" section on the wiki, for this, and a list of others.

    Edit: Here's the list from the Wiki:

    Table.Is(x => x.EntityType.Name + "Table")
    PrimaryKey.Name.Is(x => "ID")
    AutoImport.Never()
    DefaultAccess.Field()
    DefaultCascade.All()
    DefaultLazy.Always()
    DynamicInsert.AlwaysTrue()
    DynamicUpdate.AlwaysTrue()
    OptimisticLock.Is(x => x.Dirty())
    Cache.Is(x => x.AsReadOnly())
    ForeignKey.EndsWith("ID")
    

    A word of warning - some of the method names in the Wiki may be wrong. I edited the Wiki with what I could verify (i.e. DefaultCascade and DefaultLazy), but can't vouch for the rest. But you should be able to figure out the proper names with Intellisense if the need arises.

提交回复
热议问题