예제 #1
0
 public CompanyMap()
 {
       Table("Companies");
       LazyLoad();
       Id(x => x.CompanyID)
         .Column("CompanyID")
         .CustomType("Int32")
         .Access.Property()
         .CustomSqlType("INTEGER")
         .Not.Nullable()                
         .GeneratedBy.Identity();
       Map(x => x.CompanyName)    
         .Column("CompanyName")
         .CustomType("String")
         .Access.Property()
         .Generated.Never()
         .CustomSqlType("VARCHAR")
         .Not.Nullable()
         .Length(15);
       HasManyToMany<Factory>(x => x.Contractors)
         .Access.Property()
         .AsMap("ContractorID")
         .AsTernaryAssociation(
         .Cascade.None()
         .LazyLoad()
         // .OptimisticLock.Version() /*bug (or missing feature) in Fluent NHibernate*/
         .Generic()
         .Table("CompanyFactoriesContractors")
         .FetchType.Join()
         .ChildKeyColumns.Add("FactoryID", mapping => mapping.Name("FactoryID")
                                                              .SqlType("INTEGER")
                                                              .Not.Nullable())
         .ParentKeyColumns.Add("CompanyID", mapping => mapping.Name("CompanyID")
                                                              .SqlType("INTEGER")
                                                              .Not.Nullable());
 }