Beispiel #1
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");
            }
        }
Beispiel #2
0
        private static async Task SetBO1_BO2_JAsync(MyBO bo, ISession s, TBO1_BO2_J value, Action <MyRef2, int?> set, CancellationToken cancellationToken = default(CancellationToken))
        {
            switch (value)
            {
            case TBO1_BO2_J.Null:
                bo.BO1 = null;
                break;

            case TBO1_BO2_J.BO1:
                (await(bo.GetOrCreateBO1Async(s, cancellationToken))).BO2 = null;
                break;

            case TBO1_BO2_J.ValueNull:
                set(await((await(bo.GetOrCreateBO1Async(s, cancellationToken))).GetOrCreateBO2Async(s, cancellationToken)), null);
                break;

            case TBO1_BO2_J.Zero:
                set(await((await(bo.GetOrCreateBO1Async(s, cancellationToken))).GetOrCreateBO2Async(s, cancellationToken)), 0);
                break;

            case TBO1_BO2_J.One:
                set(await((await(bo.GetOrCreateBO1Async(s, cancellationToken))).GetOrCreateBO2Async(s, cancellationToken)), 1);
                break;

            default:
                throw new Exception("Value " + value + " not handled in code");
            }
        }
Beispiel #3
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");
            }
        }
 public void Set(MyBO bo, ISession s, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
 {
     if (_set1 != null)
     {
         _set1(bo, s, item1);
     }
     if (_set2 != null)
     {
         _set2(bo, s, item2);
     }
     if (_set3 != null)
     {
         _set3(bo, s, item3);
     }
     if (_set4 != null)
     {
         _set4(bo, s, item4);
     }
     if (_set5 != null)
     {
         _set5(bo, s, item5);
     }
     if (_set6 != null)
     {
         _set6(bo, s, item6);
     }
     if (_set7 != null)
     {
         _set7(bo, s, item7);
     }
 }
Beispiel #5
0
        public static async Task SetBO1_BO3_L1Async(MyBO bo, ISession s, TBO1_BO3_L value, CancellationToken cancellationToken = default(CancellationToken))
        {
            switch (value)
            {
            case TBO1_BO3_L.Null:
                bo.BO1 = null;
                break;

            case TBO1_BO3_L.BO1:
                (await(bo.GetOrCreateBO1Async(s, cancellationToken))).BO3 = null;
                break;

            case TBO1_BO3_L.ValueNull:
                (await((await(bo.GetOrCreateBO1Async(s, cancellationToken))).GetOrCreateBO3Async(s, cancellationToken))).L1 = 0;       // L1 is int, not int?
                break;

            case TBO1_BO3_L.Zero:
                (await((await(bo.GetOrCreateBO1Async(s, cancellationToken))).GetOrCreateBO3Async(s, cancellationToken))).L1 = 0;
                break;

            case TBO1_BO3_L.One:
                (await((await(bo.GetOrCreateBO1Async(s, cancellationToken))).GetOrCreateBO3Async(s, cancellationToken))).L1 = 1;
                break;

            default:
                throw new Exception("Value " + value + " not handled in code");
            }
        }
        public void LinqExploratoryTestWhichProvesNothing()
        {
            {
                var i1001 = new MyRef1 {
                    Id = 1001, I1 = null, I2 = 101
                };
                var i1101 = new MyRef1 {
                    Id = 1101, I1 = null, I2 = 111
                };
                var i1002 = new MyRef1 {
                    Id = 1002, I1 = 12, I2 = 102
                };
                var i1003 = new MyRef1 {
                    Id = 1003, I1 = 13, I2 = 103
                };

                var ref1s = new[] { i1001, i1101, i1002, i1003 };

                var someRef1s = from r in ref1s
                                orderby(r.Id == 1101 || r.Id == 1102?r.Id - 1000 : r.Id)
                                select(r.Id == 1101 || r.Id == 1102 ? r.Id + 1000 : r.Id);

                CollectionAssert.AreEqual(new[] { 2101, 1001, 1002, 1003 }, someRef1s.ToList());
            }
            {
                var j2001 = new MyRef2 {
                    Id = 2001, J1 = null, J2 = 201
                };
                var j2002 = new MyRef2 {
                    Id = 2002, J1 = 22, J2 = 202
                };

                var i1001 = new MyRef1 {
                    Id = 1001, I1 = null, I2 = 101, BO2 = j2001
                };
                var i1002 = new MyRef1 {
                    Id = 1002, I1 = 12, I2 = 102, BO2 = null
                };

                var b10 = new MyBO {
                    Id = 10, Name = "1:1001,o1:NULL,2:NULL", BO1 = i1001, OtherBO1 = null, BO2 = null
                };
                var b20 = new MyBO {
                    Id = 20, Name = "1:1002,o1:NULL,2:2002", BO1 = i1002, OtherBO1 = null, BO2 = j2002
                };

                var bos = new[] { b10 };

                //var someBos = from r in bos
                //              where r.BO1.BO2.J2 == 201
                //              select r;
                //CollectionAssert.AreEqual(new[] { b10 }, someBos.ToList());

                var someBos1 = from r in bos
                               where (r.BO1.BO2 == null ? r.BO2 : r.BO1.BO2).J2 == 201
                               select r.Id;
                Assert.That(() => someBos1.ToList(), Is.EquivalentTo(new[] { b10.Id }));
            }
        }
        private static IEnumerable <int> CreateObjects <T1, T2, T3, T4, T5, T6, T7>(ISession session, SetterTuple <T1, T2, T3, T4, T5, T6, T7> setters, Func <MyBO, bool> condition)
        {
            var  expectedIds           = new List <int>();
            bool thereAreSomeWithTrue  = false;
            bool thereAreSomeWithFalse = false;
            var  allTestCases          = GetAllTestCases <T1, T2, T3, T4, T5, T6, T7>().ToList();
            var  i = 0;

            foreach (var q in allTestCases)
            {
                MyBO bo = new MyBO();
                setters.Set(bo, session, q.Item1, q.Item2, q.Item3, q.Item4, q.Item5, q.Item6, q.Item7);
                try
                {
                    if (condition(bo))
                    {
                        expectedIds.Add(bo.Id);
                        thereAreSomeWithTrue = true;
                    }
                    else
                    {
                        thereAreSomeWithFalse = true;
                    }
                    if ((i % BatchSize) == 0)
                    {
                        if (session.Transaction.IsActive)
                        {
                            session.Transaction.Commit();
                            session.Clear();
                        }
                        session.BeginTransaction();
                    }
                    session.Save(bo);
                    i++;
                }
                catch (NullReferenceException)
                {
                    // ignore - we only check consistency with Linq2Objects in non-failing cases;
                    // emulating the outer-join logic for exceptional cases in Lin2Objects is IMO very hard.
                }
            }
            if (session.Transaction.IsActive)
            {
                session.Transaction.Commit();
                session.Clear();
            }

            Console.WriteLine("Congratulation!! you have saved " + i + " entities.");
            if (!thereAreSomeWithTrue)
            {
                throw new ArgumentException("Condition is false for all - not a good test", "condition");
            }
            if (!thereAreSomeWithFalse)
            {
                throw new ArgumentException("Condition is true for all - not a good test", "condition");
            }
            return(expectedIds);
        }
        /// <summary>
        /// This setup is used in most tests in here - but not all; and we might want to
        /// twist it for special tests. Therefore, the OnSetUp mechanism is not used.
        /// </summary>
        private void StandardSetUp()
        {
            using (var session = OpenSession())
            {
                using (var tx = session.BeginTransaction())
                {
                    var i1001 = new MyRef1 {
                        Id = 1001, I1 = null, I2 = 101
                    };
                    var i1101 = new MyRef1 {
                        Id = 1101, I1 = null, I2 = 111
                    };
                    var i1002 = new MyRef1 {
                        Id = 1002, I1 = 12, I2 = 102
                    };
                    var i1003 = new MyRef1 {
                        Id = 1003, I1 = 13, I2 = 103
                    };
                    session.Save(i1001);
                    session.Save(i1101);
                    session.Save(i1002);
                    session.Save(i1003);

                    var j2001 = new MyRef2 {
                        Id = 2001, J1 = null, J2 = 201
                    };
                    var j2002 = new MyRef2 {
                        Id = 2002, J1 = 22, J2 = 202
                    };
                    var j2003 = new MyRef2 {
                        Id = 2003, J1 = null, J2 = 203
                    };
                    session.Save(j2001);
                    session.Save(j2002);
                    session.Save(j2003);

                    var b10 = new MyBO {
                        Id = 10, Name = "1:1001,o1:NULL,2:NULL", BO1 = i1001, OtherBO1 = null, BO2 = null
                    };
                    var b11 = new MyBO {
                        Id = 11, Name = "1:1001,o1:1101,2:NULL", BO1 = i1001, OtherBO1 = i1101, BO2 = null
                    };
                    var b20 = new MyBO {
                        Id = 20, Name = "1:1002,o1:NULL,2:2002", BO1 = i1002, OtherBO1 = null, BO2 = j2002
                    };
                    var b30 = new MyBO {
                        Id = 30, Name = "1:NULL,o1:NULL,2:2003", BO1 = null, OtherBO1 = null, BO2 = j2003
                    };
                    session.Save(b10);
                    session.Save(b11);
                    session.Save(b20);
                    session.Save(b30);
                    tx.Commit();
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// This setup is used in most tests in here - but not all; and we might want to
        /// twist it for special tests. Therefore, the OnSetUp mechanism is not used.
        /// </summary>
        /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
        private async Task StandardSetUpAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            using (var session = OpenSession())
            {
                using (var tx = session.BeginTransaction())
                {
                    var i1001 = new MyRef1 {
                        Id = 1001, I1 = null, I2 = 101
                    };
                    var i1101 = new MyRef1 {
                        Id = 1101, I1 = null, I2 = 111
                    };
                    var i1002 = new MyRef1 {
                        Id = 1002, I1 = 12, I2 = 102
                    };
                    var i1003 = new MyRef1 {
                        Id = 1003, I1 = 13, I2 = 103
                    };
                    await(session.SaveAsync(i1001, cancellationToken));
                    await(session.SaveAsync(i1101, cancellationToken));
                    await(session.SaveAsync(i1002, cancellationToken));
                    await(session.SaveAsync(i1003, cancellationToken));

                    var j2001 = new MyRef2 {
                        Id = 2001, J1 = null, J2 = 201
                    };
                    var j2002 = new MyRef2 {
                        Id = 2002, J1 = 22, J2 = 202
                    };
                    var j2003 = new MyRef2 {
                        Id = 2003, J1 = null, J2 = 203
                    };
                    await(session.SaveAsync(j2001, cancellationToken));
                    await(session.SaveAsync(j2002, cancellationToken));
                    await(session.SaveAsync(j2003, cancellationToken));

                    var b10 = new MyBO {
                        Id = 10, Name = "1:1001,o1:NULL,2:NULL", BO1 = i1001, OtherBO1 = null, BO2 = null
                    };
                    var b11 = new MyBO {
                        Id = 11, Name = "1:1001,o1:1101,2:NULL", BO1 = i1001, OtherBO1 = i1101, BO2 = null
                    };
                    var b20 = new MyBO {
                        Id = 20, Name = "1:1002,o1:NULL,2:2002", BO1 = i1002, OtherBO1 = null, BO2 = j2002
                    };
                    var b30 = new MyBO {
                        Id = 30, Name = "1:NULL,o1:NULL,2:2003", BO1 = null, OtherBO1 = null, BO2 = j2003
                    };
                    await(session.SaveAsync(b10, cancellationToken));
                    await(session.SaveAsync(b11, cancellationToken));
                    await(session.SaveAsync(b20, cancellationToken));
                    await(session.SaveAsync(b30, cancellationToken));
                    await(tx.CommitAsync(cancellationToken));
                }
            }
        }
 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();
         }
     }
 }
Beispiel #11
0
        public async Task ProjectionDoesNotChangeResultAsync()
        {
            // This tests against the "projection anomaly" of (||-4) semantics.
            using (var session = OpenSession())
            {
                using (var tx = session.BeginTransaction())
                {
                    var i1001 = new MyRef1 {
                        Id = 1001, I1 = null, I2 = 101
                    };
                    var i1101 = new MyRef1 {
                        Id = 1101, I1 = null, I2 = 111
                    };
                    await(session.SaveAsync(i1001));
                    await(session.SaveAsync(i1101));

                    var b1 = new MyBO {
                        Id = 1, Name = "1:1001", BO1 = i1001
                    };
                    var b2 = new MyBO {
                        Id = 2, Name = "2:1101", BO1 = i1101
                    };
                    var b3 = new MyBO {
                        Id = 3, Name = "3:1101", BO1 = i1101
                    };
                    var b4 = new MyBO {
                        Id = 4, Name = "4:NULL", BO1 = null
                    };
                    await(session.SaveAsync(b1));
                    await(session.SaveAsync(b2));
                    await(session.SaveAsync(b3));
                    await(session.SaveAsync(b4));
                    await(tx.CommitAsync());
                }
            }

            using (var session = OpenSession())
            {
                var directResult = (await(session.Query <MyRef1>()
                                          .Where(bo => bo.I1 == null).ToListAsync())).Select(bo => bo.Id);
                var resultViaProjection = (await((from bo in session.Query <MyBO>()
                                                  where bo.BO1.I1 == null || bo.BO2.J2 == 999
                                                  select bo.BO1).Distinct().ToListAsync())).Select(bo => bo.Id);
                // With "projection anomaly", the previous Select will fail, as one "bo" is null,
                // and hence bo.Id throws a NRE.
                Assert.That(() => resultViaProjection.ToList(), Is.EquivalentTo(directResult.ToList()));
            }
        }
Beispiel #12
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");
            }
        }
Beispiel #13
0
        private static async Task SetBO1_IAsync(MyBO bo, ISession s, TBO1_I value, Action <MyRef1, int?> set, CancellationToken cancellationToken = default(CancellationToken))
        {
            switch (value)
            {
            case TBO1_I.Null:
                bo.BO1 = null;
                break;

            case TBO1_I.ValueNull:
                set(await(bo.GetOrCreateBO1Async(s, cancellationToken)), null);
                break;

            case TBO1_I.Zero:
                set(await(bo.GetOrCreateBO1Async(s, cancellationToken)), 0);
                break;

            case TBO1_I.One:
                set(await(bo.GetOrCreateBO1Async(s, cancellationToken)), 1);
                break;

            default:
                throw new NotImplementedException("Value " + value + " not handled in code");
            }
        }
Beispiel #14
0
        private static void SetBO1_I(MyBO bo, ISession s, TBO1_I value, Action <MyRef1, int?> set)
        {
            switch (value)
            {
            case TBO1_I.Null:
                bo.BO1 = null;
                break;

            case TBO1_I.ValueNull:
                set(bo.GetOrCreateBO1(s), null);
                break;

            case TBO1_I.Zero:
                set(bo.GetOrCreateBO1(s), 0);
                break;

            case TBO1_I.One:
                set(bo.GetOrCreateBO1(s), 1);
                break;

            default:
                throw new NotImplementedException("Value " + value + " not handled in code");
            }
        }
Beispiel #15
0
 public static Task SetBO1_I3Async(MyBO bo, ISession s, TBO1_I value, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(SetBO1_IAsync(bo, s, value, (b, i) => b.I3 = i ?? 0, cancellationToken));
 }
Beispiel #16
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");
     }
 }
Beispiel #17
0
 public static void SetK3(MyBO bo, ISession s, TK value)
 {
     bo.K3 = value == TK.One ? 1 : 0;
 }
Beispiel #18
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);
 }
Beispiel #19
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);
 }
Beispiel #20
0
 public static void SetBO1_I3(MyBO bo, ISession s, TBO1_I value)
 {
     SetBO1_I(bo, s, value, (b, i) => b.I3 = i ?? 0);
 }
Beispiel #21
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");
     }
 }
Beispiel #22
0
 public static void SetK3(MyBO bo, ISession s, TK value)
 {
     bo.K3 = value == TK.One ? 1 : 0;
 }
Beispiel #23
0
 public static void SetBO1_I1(MyBO bo, ISession s, TBO1_I value)
 {
     SetBO1_I(bo, s, value, (b, i) => b.I1 = i);
 }
Beispiel #24
0
 public static void SetBO1_I1(MyBO bo, ISession s, TBO1_I value)
 {
     SetBO1_I(bo, s, value, (b, i) => b.I1 = i);
 }
Beispiel #25
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");
     }
 }
Beispiel #26
0
 public static void SetBO1_I3(MyBO bo, ISession s, TBO1_I value)
 {
     SetBO1_I(bo, s, value, (b, i) => b.I3 = i ?? 0);
 }
Beispiel #27
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);
 }
Beispiel #28
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);
 }
Beispiel #29
0
 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();
         }
 }
Beispiel #30
0
 public static Task Set_BO1_BO2_J2Async(MyBO bo, ISession s, TBO1_BO2_J value, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(SetBO1_BO2_JAsync(bo, s, value, (b, i) => b.J2 = i ?? 0, cancellationToken));
 }