コード例 #1
0
        public void CheckMaterialiseQueryStrategy()
        {
            Func<string> GetName = () => "Marc";
            var repository = new EntityFrameworkQueryRepository(new FamilyDbContext());

            // Show it's not working due to running in the db
            Assert.Throws<NotSupportedException>(() =>
            {
                repository.GetEntity<Child>(
                    new ExpressionQueryStrategy<Child>(p => p.FirstName == GetName()))
                    .LastName.ShouldEqual("Burgess");
            });

            // Now show MaterialiseQueryStrategy does work
            repository.GetEntity<Child>(
                new MaterialiseQueryStrategy(),
                new ExpressionQueryStrategy<Child>(p => p.FirstName == GetName().ToString()))
                .LastName.ShouldEqual("Burgess");
        }
コード例 #2
0
        public void CheckMaterialiseQueryStrategy()
        {
            Func <string> GetName    = () => "Marc";
            var           repository = new EntityFrameworkQueryRepository(new FamilyDbContext());

            // Show it's not working due to running in the db
            Assert.Throws <NotSupportedException>(() =>
            {
                repository.GetEntity <Child>(
                    new ExpressionQueryStrategy <Child>(p => p.FirstName == GetName()))
                .LastName.ShouldEqual("Burgess");
            });

            // Now show MaterialiseQueryStrategy does work
            repository.GetEntity <Child>(
                new MaterialiseQueryStrategy(),
                new ExpressionQueryStrategy <Child>(p => p.FirstName == GetName().ToString()))
            .LastName.ShouldEqual("Burgess");
        }
コード例 #3
0
        public void LoadTest()
        {
            var repository = new EntityFrameworkQueryRepository(new FamilyDbContext());
            var person     = repository.GetEntity <Parent>(p => p.Id == Names.IsabelleOsborne);

            person.Children.Count.ShouldEqual(0);

            repository.Load(person, p => p.Children);

            person.Children.Count.ShouldEqual(2);
        }
コード例 #4
0
        public void LoadTest()
        {
            var repository = new EntityFrameworkQueryRepository(new FamilyDbContext());
            var person = repository.GetEntity<Parent>(p => p.Id == Names.IsabelleOsborne);
            person.Children.Count.ShouldEqual(0);

            repository.Load(person, p => p.Children);

            person.Children.Count.ShouldEqual(2);
        }