Esempio n. 1
0
        protected override void Initialize()
        {
            var str1 = new StrTestPrivSeqEntity {
                Str = "a"
            };
            var str2 = new StrTestPrivSeqEntity {
                Str = "b"
            };
            var int1 = new IntTestPrivSeqEntity {
                Number = 1
            };
            var int2 = new IntTestPrivSeqEntity {
                Number = 2
            };
            var map1 = new TernaryMapEntity();
            var map2 = new TernaryMapEntity();

            // Revision 1 (map1: initialy one mapping int1 -> str1, map2: empty)
            using (var tx = Session.BeginTransaction())
            {
                str1_id        = (int)Session.Save(str1);
                str2_id        = (int)Session.Save(str2);
                int1_id        = (int)Session.Save(int1);
                int2_id        = (int)Session.Save(int2);
                map1.Map[int1] = str1;
                map1_id        = (int)Session.Save(map1);
                map2_id        = (int)Session.Save(map2);
                tx.Commit();
            }
            // Revision 2 (map1: replacing the mapping, map2: adding two mappings)
            using (var tx = Session.BeginTransaction())
            {
                map1.Map[int1] = str2;
                map2.Map[int1] = str1;
                map2.Map[int2] = str1;
                tx.Commit();
            }
            // Revision 3 (map1: removing a non-existing mapping, adding an existing mapping - no changes, map2: removing a mapping)
            using (var tx = Session.BeginTransaction())
            {
                map1.Map.Remove(int2);
                map1.Map[int1] = str2;
                map2.Map.Remove(int1);
                tx.Commit();
            }
            // Revision 4 (map1: adding a mapping, map2: adding a mapping)
            using (var tx = Session.BeginTransaction())
            {
                map1.Map[int2] = str2;
                map2.Map[int1] = str2;
                tx.Commit();
            }
        }
        protected override void Initialize()
        {
            var str1 = new StrTestPrivSeqEntity {
                Str = "a"
            };
            var str2 = new StrTestPrivSeqEntity {
                Str = "b"
            };
            var int1 = new IntTestPrivSeqEntity {
                Number = 1
            };
            var int2 = new IntTestPrivSeqEntity {
                Number = 2
            };
            var map1 = new TernaryMapEntity();

            // Revision 1 (int1 -> str1)
            using (var tx = Session.BeginTransaction())
            {
                str1_id        = (int)Session.Save(str1);
                str2_id        = (int)Session.Save(str2);
                int1_id        = (int)Session.Save(int1);
                int2_id        = (int)Session.Save(int2);
                map1.Map[int1] = str1;
                map1_id        = (int)Session.Save(map1);
                tx.Commit();
            }
            // Revision 2 (removing int1->str1, flushing, adding int1->str1 again and a new int2->str2 mapping to force a change)
            using (var tx = Session.BeginTransaction())
            {
                map1.Map = new Dictionary <IntTestPrivSeqEntity, StrTestPrivSeqEntity>();
                Session.Flush();
                map1.Map[int1] = str1;
                map1.Map[int2] = str2;
                tx.Commit();
            }
            // Revision 3 (removing int1->str1, flushing, overwriting int2->str1)
            using (var tx = Session.BeginTransaction())
            {
                map1.Map.Remove(int1);
                Session.Flush();
                map1.Map[int2] = str1;
                tx.Commit();
            }
        }