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"); }
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"); }
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); }
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); }