Exemple #1
0
 public void SetUp()
 {
     _row    = new Row();
     _mapper = new EntityMapper(new ConventionReader(new DefaultConvention()));
     _parentChildRelation     = ObjectRelation.CreateTwoWay <Parent, Child>(x => x.Children, x => x.Parent);
     _childParentRelation     = ObjectRelation.CreateTwoWay <Parent, Child>(x => x.Children, x => x.Parent);
     _childGrandChildRelation = ObjectRelation.CreateTwoWay <Child, GrandChild>(x => x.GrandChildren, x => x.Child);
     _idLessRelation          = ObjectRelation.CreateTwoWay <ParentWithoutId, ChildWithoutId>(x => x.Children, x => x.Parent);
 }
Exemple #2
0
        public void Insantiates_collection_when_creating_graph_with_parent_having_null_collection()
        {
            _row.Add("Child Id", 1);
            _row.Add("Parent Id", 2);

            var relation = ObjectRelation.CreateTwoWay <NullCollectionParent, ChildWithNullCollectionParent>(x => x.Children, x => x.Parent);

            var parent = _mapper.CreateInstanceGraph <NullCollectionParent>(_row, relation);

            Assert.AreEqual(1, parent.Children.Count);
        }
Exemple #3
0
        public void Foreign_key_value_is_written_to_foreign_key_value_property_even_if_reference_property_for_same_foreign_key_exists_when_creating_graph()
        {
            _row.Add("ChildWithForeignKeyColumn Id", 1);
            _row.Add("ChildWithForeignKeyColumn ParentId", 2);
            _row.Add("ParentToChildWithForeignKeyColumn Id", 3);

            var relation = ObjectRelation.CreateTwoWay <ParentToChildWithForeignKeyColumn, ChildWithForeignKeyColumn>(x => x.Children, x => x.Parent);
            var child    = _mapper.CreateInstanceGraph <ChildWithForeignKeyColumn>(_row, relation);

            Assert.AreEqual(1, child.Id);
            Assert.AreEqual(2, child.ParentId);
            Assert.AreEqual(3, child.Parent.Id);
        }