protected override void OnSetUp()
 {
     using (var session = OpenSession())
     {
         using (var tx = session.BeginTransaction())
         {
             {
                 var bLeftLeft = new MyBO { Id = 111, Name = "1LL", K2 = 1, K1 = 1 };
                 var bLeftRight = new MyBO { Id = 112, Name = "1LR", K2 = 1 };
                 var bLeft = new MyBO { Id = 11, Name = "1L", LeftSon = bLeftLeft, RightSon = bLeftRight, K1 = 1 };
                 var bRightRight = new MyBO { Id = 122, Name = "1RR", K2 = 1, K1 = 1 };
                 var bRight = new MyBO { Id = 12, Name = "1R", RightSon = bRightRight, K1 = 1 };
                 var bRoot = new MyBO { Id = 1, Name = "1", LeftSon = bLeft, RightSon = bRight };
                 session.Save(bLeftLeft);
                 session.Save(bLeftRight);
                 session.Save(bLeft);
                 session.Save(bRightRight);
                 session.Save(bRight);
                 session.Save(bRoot);
             }
             {
                 var bLeftRight = new MyBO { Id = 212, Name = "2LR", K2 = 2 };
                 var bLeft = new MyBO { Id = 21, Name = "2L", RightSon = bLeftRight };
                 var bRightRight = new MyBO { Id = 222, Name = "2RR", K2 = 2 };
                 var bRight = new MyBO { Id = 22, Name = "2R", RightSon = bRightRight };
                 var bRoot = new MyBO { Id = 2, Name = "2", LeftSon = bLeft, RightSon = bRight };
                 session.Save(bLeftRight);
                 session.Save(bLeft);
                 session.Save(bRightRight);
                 session.Save(bRight);
                 session.Save(bRoot);
             }
             {
                 var bLeftLeft = new MyBO { Id = 311, Name = "3LL", K2 = 3 };
                 var bLeftRight = new MyBO { Id = 312, Name = "3LR", K2 = 3 };
                 var bLeft = new MyBO { Id = 31, Name = "3L", LeftSon = bLeftLeft, RightSon = bLeftRight };
                 var bRight = new MyBO { Id = 32, Name = "3R" };
                 var bRoot = new MyBO { Id = 3, Name = "3", LeftSon = bLeft, RightSon = bRight };
                 session.Save(bLeftLeft);
                 session.Save(bLeftRight);
                 session.Save(bLeft);
                 session.Save(bRight);
                 session.Save(bRoot);
             }
             {
                 var bLeft = new MyBO { Id = 41, Name = "4L" };
                 var bRight = new MyBO { Id = 42, Name = "4R" };
                 var bRoot = new MyBO { Id = 4, Name = "4", LeftSon = bLeft, RightSon = bRight };
                 session.Save(bLeft);
                 session.Save(bRight);
                 session.Save(bRoot);
             }
             tx.Commit();
         }
     }
 }
Exemplo n.º 2
0
 public static void SetBO1_BO3_L1(MyBO bo, ISession s, TBO1_BO3_L value)
 {
     switch (value)
     {
         case TBO1_BO3_L.Null:
             bo.BO1 = null;
             break;
         case TBO1_BO3_L.BO1:
             bo.GetOrCreateBO1(s).BO3 = null;
             break;
         case TBO1_BO3_L.ValueNull:
             bo.GetOrCreateBO1(s).GetOrCreateBO3(s).L1 = 0; // L1 is int, not int?
             break;
         case TBO1_BO3_L.Zero:
             bo.GetOrCreateBO1(s).GetOrCreateBO3(s).L1 = 0;
             break;
         case TBO1_BO3_L.One:
             bo.GetOrCreateBO1(s).GetOrCreateBO3(s).L1 = 1;
             break;
         default:
             throw new Exception("Value " + value + " not handled in code");
     }
 }
Exemplo n.º 3
0
 public static void Set_BO1_BO2_J2(MyBO bo, ISession s, TBO1_BO2_J value)
 {
     SetBO1_BO2_J(bo, s, value, (b, i) => b.J2 = i ?? 0);
 }
Exemplo n.º 4
0
 public static void SetBO1_BO2_J1(MyBO bo, ISession s, TBO1_BO2_J value)
 {
     SetBO1_BO2_J(bo, s, value, (b, i) => b.J1 = i);
 }
Exemplo n.º 5
0
 private static void SetBO1_BO2_J(MyBO bo, ISession s, TBO1_BO2_J value, Action<MyRef2, int?> set)
 {
     switch (value)
     {
         case TBO1_BO2_J.Null:
             bo.BO1 = null;
             break;
         case TBO1_BO2_J.BO1:
             bo.GetOrCreateBO1(s).BO2 = null;
             break;
         case TBO1_BO2_J.ValueNull:
             set(bo.GetOrCreateBO1(s).GetOrCreateBO2(s), null);
             break;
         case TBO1_BO2_J.Zero:
             set(bo.GetOrCreateBO1(s).GetOrCreateBO2(s), 0);
             break;
         case TBO1_BO2_J.One:
             set(bo.GetOrCreateBO1(s).GetOrCreateBO2(s), 1);
             break;
         default:
             throw new Exception("Value " + value + " not handled in code");
     }
 }
Exemplo n.º 6
0
 public static void SetBO1_I3(MyBO bo, ISession s, TBO1_I value)
 {
     SetBO1_I(bo, s, value, (b, i) => b.I3 = i ?? 0);
 }
Exemplo n.º 7
0
 public static void SetBO1_I1(MyBO bo, ISession s, TBO1_I value)
 {
     SetBO1_I(bo, s, value, (b, i) => b.I1 = i);
 }
Exemplo n.º 8
0
 public static void SetK3(MyBO bo, ISession s, TK value)
 {
     bo.K3 = value == TK.One ? 1 : 0;
 }
Exemplo n.º 9
0
 public static void SetK1(MyBO bo, ISession s, TK value)
 {
     switch (value)
     {
         case TK.ValueNull:
             bo.K1 = null;
             break;
         case TK.Zero:
             bo.K1 = 0;
             break;
         case TK.One:
             bo.K1 = 1;
             break;
         default:
             throw new Exception("Value " + value + " not handled in code");
     }
 }