Guest User

Untitled

a guest
Jan 16th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. namespace Vuscode.Framework.NHibernate.Conventions
  2. {
  3. using FluentNHibernate.Conventions;
  4. using FluentNHibernate.Conventions.Instances;
  5.  
  6. public class DefaultStringPropertyConvention : IPropertyConvention
  7. {
  8. public void Apply(IPropertyInstance instance)
  9. {
  10. instance.Length(100);
  11. instance.Nullable();
  12. }
  13. }
  14. }
  15.  
  16. namespace Vuscode.Framework.NHibernate.Conventions
  17. {
  18. using FluentNHibernate.Conventions;
  19. using FluentNHibernate.Conventions.Instances;
  20.  
  21. public class DefaultBoolPropertyConvention : IPropertyConvention
  22. {
  23. public void Apply(IPropertyInstance instance)
  24. {
  25. instance.Not.Nullable();
  26. instance.Default("0");
  27. }
  28. }
  29. }
  30.  
  31. public void Apply(IPropertyInstance instance)
  32. {
  33. if (instance.Type == typeof(bool))
  34. {
  35. instance.Not.Nullable();
  36. instance.Default("0");
  37. }
  38. }
  39.  
  40. // or
  41.  
  42. public class DefaultBoolPropertyConvention : IPropertyConvention, IPropertyConventionAcceptance
  43. {
  44. public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
  45. {
  46. criteria.Expect(i => i.Type == typeof(bool));
  47. }
  48.  
  49. public void Apply(IPropertyInstance instance)
  50. {
  51. instance.Not.Nullable();
  52. instance.Default("0");
  53.  
  54. }
  55. }
Add Comment
Please, Sign In to add comment