root/UnityWeb/UnityWeb/Repository/NHibernateDataAccess/NHibernateSessionManager.cs
| 55 | 56 | ||
|---|---|---|---|
18 | public class NHibernateSessionManager : INHibernateSessionManager | 18 | public class NHibernateSessionManager : INHibernateSessionManager |
19 | { | 19 | { |
20 | private static readonly Configuration configuration = MsSqlConfiguration.MsSql2005 | 20 | private static readonly Configuration configuration = MsSqlConfiguration.MsSql2005 |
21 | .ConnectionString.FromConnectionStringWithKey("AdventureWorksConnection") | 21 | .ConnectionString.FromConnectionStringWithKey("NorthwindConnection") |
22 | .Dialect("NHibernate.Dialect.MsSql2005Dialect") | 22 | .Dialect("NHibernate.Dialect.MsSql2005Dialect") |
23 | .Driver("NHibernate.Driver.SqlClientDriver") | 23 | .Driver("NHibernate.Driver.SqlClientDriver") |
24 | .Provider("NHibernate.Connection.DriverConnectionProvider") | 24 | .Provider("NHibernate.Connection.DriverConnectionProvider") |
... | ... | ||
62 | .WithConvention(convention => convention.GetTableName = type => type.Name + "s") | 62 | .WithConvention(convention => convention.GetTableName = type => type.Name + "s") |
63 | .WithConvention(convention => convention.GetPrimaryKeyNameFromType = type => type.Name + "ID") | 63 | .WithConvention(convention => convention.GetPrimaryKeyNameFromType = type => type.Name + "ID") |
64 | .WithConvention(convention => convention.GetForeignKeyName = prop => prop.Name + "ID") | 64 | .WithConvention(convention => convention.GetForeignKeyName = prop => prop.Name + "ID") |
65 | .WithConvention(c => c.OneToManyConvention = m => | ||
66 | { | ||
67 | m.Cascade.All(); | ||
68 | m.LazyLoad(); | ||
69 | }) | ||
65 | .ForTypesThatDeriveFrom<Employee>(autoMap => | 70 | .ForTypesThatDeriveFrom<Employee>(autoMap => |
66 | { | 71 | { |
67 | autoMap.Map(p => p.JobTitle, "Title"); | 72 | autoMap.Map(p => p.JobTitle, "Title"); |
... | ... | ||
74 | autoMap.Map(p => p.CompanyName).CanNotBeNull(); | 79 | autoMap.Map(p => p.CompanyName).CanNotBeNull(); |
75 | }) | 80 | }) |
76 | .ForTypesThatDeriveFrom<Category>(autoMap => | 81 | .ForTypesThatDeriveFrom<Category>(autoMap => |
77 | |||
78 | { | 82 | { |
79 | autoMap.WithTable("Categories"); | 83 | autoMap.WithTable("Categories"); |
80 | autoMap.Map(p => p.Name, "CategoryName"); | 84 | autoMap.Map(p => p.Name, "CategoryName"); |
Download diff