protected override void Initialize()
        {
            var parent = new IndexedListJoinColumnBidirectionalRefIngEntity {
                References = new List <IndexedListJoinColumnBidirectionalRefEdEntity>(), Data = "data"
            };
            var child1 = new IndexedListJoinColumnBidirectionalRefEdEntity {
                Data = "data"
            };
            var child2 = new IndexedListJoinColumnBidirectionalRefEdEntity {
                Data = "data"
            };

            //only valid rev for parent
            using (var tx = Session.BeginTransaction())
            {
                parentId = (int)Session.Save(parent);
                Session.Save(child1);
                Session.Save(child2);
                tx.Commit();
            }
            //no rev for adding
            using (var tx = Session.BeginTransaction())
            {
                parent.References.Add(child1);
                parent.References.Add(child2);
                tx.Commit();
            }
            //no rev for modification
            using (var tx = Session.BeginTransaction())
            {
                parent.References.Clear();
                parent.References.Add(child2);
                parent.References.Add(child1);
                tx.Commit();
            }
            //no rev for delete
            using (var tx = Session.BeginTransaction())
            {
                parent.References.Clear();
                tx.Commit();
            }
        }
Пример #2
0
        protected override void Initialize()
        {
            // Revision 1 (ing1: ed1, ed2, ed3)
            using (var tx = Session.BeginTransaction())
            {
                var ed1 = new IndexedListJoinColumnBidirectionalRefEdEntity {
                    Data = "ed1"
                };
                var ed2 = new IndexedListJoinColumnBidirectionalRefEdEntity {
                    Data = "ed2"
                };
                var ed3 = new IndexedListJoinColumnBidirectionalRefEdEntity {
                    Data = "ed3"
                };

                var ing1 = new IndexedListJoinColumnBidirectionalRefIngEntity {
                    Data = "coll1", References = new List <IndexedListJoinColumnBidirectionalRefEdEntity> {
                        ed1, ed2, ed3
                    }
                };
                var ing2 = new IndexedListJoinColumnBidirectionalRefIngEntity {
                    Data = "coll1"
                };

                ed1_id  = (int)Session.Save(ed1);
                ed2_id  = (int)Session.Save(ed2);
                ed3_id  = (int)Session.Save(ed3);
                ing1_id = (int)Session.Save(ing1);
                ing2_id = (int)Session.Save(ing2);
                tx.Commit();
                Session.Clear();
            }
            // Revision 2 (ing1: ed1, ed3, ing2: ed2)
            using (var tx = Session.BeginTransaction())
            {
                var ing1 = Session.Get <IndexedListJoinColumnBidirectionalRefIngEntity>(ing1_id);
                var ing2 = Session.Get <IndexedListJoinColumnBidirectionalRefIngEntity>(ing2_id);
                var ed2  = Session.Get <IndexedListJoinColumnBidirectionalRefEdEntity>(ed2_id);
                ing1.References.Remove(ed2);
                ing2.References.Add(ed2);
                tx.Commit();
                Session.Clear();
            }
            // Revision 3 (ing1: ed3, ed1, ing2: ed2)
            using (var tx = Session.BeginTransaction())
            {
                var ing1 = Session.Get <IndexedListJoinColumnBidirectionalRefIngEntity>(ing1_id);
                var ed3  = Session.Get <IndexedListJoinColumnBidirectionalRefEdEntity>(ed3_id);
                ing1.References.Remove(ed3);
                ing1.References.Insert(0, ed3);
                tx.Commit();
                Session.Clear();
            }
            // Revision 4 (ing1: ed2, ed3, ed1)
            using (var tx = Session.BeginTransaction())
            {
                var ing1 = Session.Get <IndexedListJoinColumnBidirectionalRefIngEntity>(ing1_id);
                var ing2 = Session.Get <IndexedListJoinColumnBidirectionalRefIngEntity>(ing2_id);
                var ed2  = Session.Get <IndexedListJoinColumnBidirectionalRefEdEntity>(ed2_id);
                ing2.References.Remove(ed2);
                ing1.References.Insert(0, ed2);
                tx.Commit();
            }
        }