Esempio n. 1
0
        protected override void Initialize()
        {
            var entity = new TernaryMapEntity();
            var index  = new IntTestPrivSeqEntity {
                Number = 1
            };
            var element = new StrTestPrivSeqEntity {
                Str = "1"
            };

            entity.Map[index] = element;

            //Revision 1
            using (var tx = Session.BeginTransaction())
            {
                Session.Save(index);
                Session.Save(element);
                id = (int)Session.Save(entity);
                tx.Commit();
            }

            //Revision 2
            using (var tx = Session.BeginTransaction())
            {
                index.Number = 2;
                element.Str  = "2";
                tx.Commit();
            }

            //Revision 3
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(entity);
                Session.Delete(index);
                Session.Delete(element);
                tx.Commit();
            }
        }
Esempio n. 2
0
        protected override void Initialize()
        {
            var refEdEntity1 = new SetRefEdEntity {
                Id = 1, Data = "Demo Data 1"
            };
            var refIngEntity1 = new SetRefIngEntity {
                Id = 2, Data = "Example Data 1", Reference = refEdEntity1
            };

            //Revision 1
            using (var tx = Session.BeginTransaction())
            {
                Session.Save(refEdEntity1);
                Session.Save(refIngEntity1);
                tx.Commit();
            }

            //Revision 2 - removing both object in the same revision
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(refIngEntity1);
                Session.Delete(refEdEntity1);
                tx.Commit();
            }

            var refEdEntity2 = new SetRefEdEntity {
                Id = 3, Data = "Demo Data 2"
            };
            var refIngEntity2 = new SetRefIngEntity {
                Id = 4, Data = "Example Data 2", Reference = refEdEntity2
            };

            //Revision 3
            using (var tx = Session.BeginTransaction())
            {
                Session.Save(refEdEntity2);
                Session.Save(refIngEntity2);
                tx.Commit();
            }

            //Revision 4 - removing child object
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(refIngEntity2);
                tx.Commit();
            }

            //Revision 5 - removing parent object
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(refEdEntity2);
                tx.Commit();
            }

            var setOwningEntity1 = new SetOwningEntity {
                Id = 5, Data = "Demo Data 1"
            };
            var setOwnedEntity1 = new SetOwnedEntity {
                Id = 6, Data = "Example Data 1"
            };
            var owning = new HashSet <SetOwningEntity>();
            var owned  = new HashSet <SetOwnedEntity>();

            owning.Add(setOwningEntity1);
            owned.Add(setOwnedEntity1);
            setOwningEntity1.References = owned;
            setOwnedEntity1.Referencing = owning;

            //Revision 6
            using (var tx = Session.BeginTransaction())
            {
                Session.Save(setOwnedEntity1);
                Session.Save(setOwningEntity1);
                tx.Commit();
            }

            //Revision 7 - removing both object in the same revision
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(setOwningEntity1);
                Session.Delete(setOwnedEntity1);
                tx.Commit();
            }

            var setOwningEntity2 = new SetOwningEntity {
                Id = 7, Data = "Demo Data 2"
            };
            var setOwnedEntity2 = new SetOwnedEntity {
                Id = 8, Data = "Example Data 2"
            };

            owning = new HashSet <SetOwningEntity>();
            owned  = new HashSet <SetOwnedEntity>();
            owning.Add(setOwningEntity2);
            owned.Add(setOwnedEntity2);
            setOwningEntity2.References = owned;
            setOwnedEntity2.Referencing = owning;

            //Revision 8
            using (var tx = Session.BeginTransaction())
            {
                Session.Save(setOwnedEntity2);
                Session.Save(setOwningEntity2);
                tx.Commit();
            }

            //Revision 9 - removing first object
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(setOwningEntity2);
                tx.Commit();
            }

            //Revision 10 - removing second object
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(setOwnedEntity2);
                tx.Commit();
            }

            var stringSetEntity = new StringSetEntity();

            stringSetEntity.Strings.Add("string 1");
            stringSetEntity.Strings.Add("string 2");

            //Revision 11
            using (var tx = Session.BeginTransaction())
            {
                stringSetId = (int)Session.Save(stringSetEntity);
                tx.Commit();
            }

            //Revision 12 - removing element collection
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(stringSetEntity);
                tx.Commit();
            }

            unversionedEntity1 = new UnversionedStrTestEntity {
                Str = "string 1"
            };
            unversionedEntity2 = new UnversionedStrTestEntity {
                Str = "string 2"
            };
            var relationNotAuditedEntity = new M2MIndexedListTargetNotAuditedEntity {
                Id = 1, Data = "Parent"
            };

            relationNotAuditedEntity.References.Add(unversionedEntity1);
            relationNotAuditedEntity.References.Add(unversionedEntity2);
            //Revision 13
            using (var tx = Session.BeginTransaction())
            {
                Session.Save(unversionedEntity1);
                Session.Save(unversionedEntity2);
                Session.Save(relationNotAuditedEntity);
                tx.Commit();
            }

            //Revision 14 - removing entity with unversioned relation
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(relationNotAuditedEntity);
                tx.Commit();
            }

            stringEntity1 = new StrTestPrivSeqEntity {
                Str = "value 1"
            };
            stringEntity2 = new StrTestPrivSeqEntity {
                Str = "value 2"
            };
            intEntity1 = new IntTestPrivSeqEntity {
                Number = 1
            };
            intEntity2 = new IntTestPrivSeqEntity {
                Number = 2
            };
            var mapEntity = new TernaryMapEntity();

            mapEntity.Map[intEntity1] = stringEntity1;
            mapEntity.Map[intEntity2] = stringEntity2;
            //Revision 15
            using (var tx = Session.BeginTransaction())
            {
                Session.Save(stringEntity1);
                Session.Save(stringEntity2);
                Session.Save(intEntity1);
                Session.Save(intEntity2);
                ternaryMapId = (int)Session.Save(mapEntity);
                tx.Commit();
            }

            //Revision 16 - updating ternary map
            using (var tx = Session.BeginTransaction())
            {
                intEntity2.Number = 3;
                stringEntity2.Str = "Value 3";
                tx.Commit();
            }

            // Revision 17 - removing ternary map
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(mapEntity);
                tx.Commit();
            }

            var collEd1 = new CollectionRefEdEntity {
                Id = 1, Data = "data_ed_1"
            };
            var collIng1 = new CollectionRefIngEntity {
                Id = 2, Data = "data_ing_1", Reference = collEd1
            };

            collEd1.Reffering = new List <CollectionRefIngEntity> {
                collIng1
            };

            //Revision 18 - testing one-to-many collection
            using (var tx = Session.BeginTransaction())
            {
                Session.Save(collEd1);
                Session.Save(collIng1);
                tx.Commit();
            }

            //Revision 19
            using (var tx = Session.BeginTransaction())
            {
                collIng1.Data = "modified data_ing_1";
                tx.Commit();
            }

            //Revision 20
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(collIng1);
                Session.Delete(collEd1);
                tx.Commit();
            }

            var listEd1 = new ListOwnedEntity {
                Id = 1, Data = "data_ed_1"
            };
            var listIng1 = new ListOwningEntity {
                Id = 2, Data = "data_ing_1"
            };

            listEd1.Referencing = new List <ListOwningEntity> {
                listIng1
            };
            listIng1.References = new List <ListOwnedEntity> {
                listEd1
            };

            //Revision 21
            using (var tx = Session.BeginTransaction())
            {
                Session.Save(listEd1);
                Session.Save(listIng1);
                tx.Commit();
            }

            //Revision 22
            using (var tx = Session.BeginTransaction())
            {
                listIng1.Data = "modified data_ing_1";
                tx.Commit();
            }

            //Revision 23
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(listIng1);
                Session.Delete(listEd1);
                tx.Commit();
            }
        }