Exemple #1
0
        public void Implicit_Join_On_Nullable_NotNullable()
        {
            // Arrange
            var repository = new MemoryRepository(new CoreTestsMappingSourceManager());

            ClassG1 g1 = new ClassG1()
            {
                RowId = Guid.NewGuid()
            };

            repository.Insert(g1);

            ClassG1 g2 = new ClassG1()
            {
                RowId = Guid.NewGuid()
            };

            repository.Insert(g2);

            repository.Insert(new ClassG2()
            {
                RowIdRef = g1.RowId.Value
            });
            repository.Insert(new ClassG2()
            {
                RowIdRef = g1.RowId.Value
            });
            repository.Insert(new ClassG2()
            {
                RowIdRef = g2.RowId.Value
            });

            // Act
            LoadOptions options = new LoadOptions();

            options.LoadWith <ClassG1>(g => g.ClassG2s);

            var reloadedG1 = repository.All <ClassG1>(options).Where(g => g.RowId == g1.RowId).First();

            // Assert
            Assert.IsNotNull(reloadedG1.ClassG2s);
            Assert.AreEqual(2, reloadedG1.ClassG2s.Count);
        }
Exemple #2
0
        public void Explicit_Join_On_NotNullable_Nullable()
        {
            // Arrange
            var repository = new MemoryRepository(new CoreTestsMappingSourceManager());

            ClassG1 g1 = new ClassG1()
            {
                RowId = Guid.NewGuid()
            };

            repository.Insert(g1);

            ClassG1 g2 = new ClassG1()
            {
                RowId = Guid.NewGuid()
            };

            repository.Insert(g2);

            repository.Insert(new ClassG2()
            {
                RowIdRef = g1.RowId.Value
            });
            repository.Insert(new ClassG2()
            {
                RowIdRef = g1.RowId.Value
            });
            repository.Insert(new ClassG2()
            {
                RowIdRef = g2.RowId.Value
            });

            // Act
            var reloadedG2s = repository.All <ClassG2>().Where(g => g.ClassG1.RowId == g1.RowId).ToList();

            // Assert
            Assert.AreEqual(2, reloadedG2s.Count);
            Assert.IsNull(reloadedG2s.First().ClassG1);
        }