Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. private static ISessionFactory Configure()
  2. {
  3. if (_factory != null)
  4. return _factory;
  5.  
  6. var configuration = new Configuration().Configure();
  7.  
  8. // I could set my assembly of mapping here, but it's on our internal framework
  9. var fluentConfiguration = Fluently.Configure(configuration)
  10. //.Mappings(c => c.FluentMappings.AddFromAssembly(typeof(ProductMap)))
  11. .BuildConfiguration();
  12.  
  13. _factory = fluentConfiguration.BuildSessionFactory();
  14.  
  15. return _factory;
  16. }
  17.  
  18. <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  19. <session-factory>
  20. <!-- other configs here...-->
  21. <mapping assembly="MyApplication.Data.Mapping" />
  22. </session-factory>
  23. </hibernate-configuration>
  24.  
  25. private static ISessionFactory Configure()
  26. {
  27. if (_factory != null)
  28. return _factory;
  29.  
  30. var configuration = new Configuration().Configure();
  31.  
  32. foreach(var alteration in alterations)
  33. {
  34. alteration.AddTo(configuration);
  35. }
  36.  
  37. _factory = fluentConfiguration.BuildSessionFactory();
  38.  
  39. return _factory;
  40. }
  41.  
  42. // in your alteration
  43. Configuration AddTo(Configuration config)
  44. {
  45. return Fluently.Configure(config)
  46. .Mappings(c => c.FluentMappings.AddFromAssembly(typeof(ProductMap)))
  47. .BuildConfiguration();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement