diff --git a/Build/Build.cs b/Build/Build.cs index 101185e6..cbde9cd6 100644 --- a/Build/Build.cs +++ b/Build/Build.cs @@ -135,7 +135,7 @@ protected override void OnBuildInitialized() { Log.Information("Generating NuGet packages for projects in solution"); int commitNum = 0; - string NuGetVersionCustom = "2.0.0.884"; + string NuGetVersionCustom = "2.0.0.885"; //if it's not a tagged release - append the commit number to the package version diff --git a/Src/RCommon.EfCore/Crud/EFCoreRepository.cs b/Src/RCommon.EfCore/Crud/EFCoreRepository.cs index cec2eca2..ea9b7cb1 100644 --- a/Src/RCommon.EfCore/Crud/EFCoreRepository.cs +++ b/Src/RCommon.EfCore/Crud/EFCoreRepository.cs @@ -90,12 +90,13 @@ public override bool Tracking public override IEagerLoadableQueryable Include(Expression> path) { - _includableQueryable = RepositoryQuery.Include(path); + _includableQueryable = ObjectContext.Set().Include(path); return this; } public override IEagerLoadableQueryable ThenInclude(Expression> path) { + // TODO: This is likely a bug. The received is incorrect. _repositoryQuery = _includableQueryable.ThenInclude(path); return this; } diff --git a/Tests/RCommon.Persistence.EFCore.Tests/EFCoreRepositoryIntegrationTests.cs b/Tests/RCommon.Persistence.EFCore.Tests/EFCoreRepositoryIntegrationTests.cs index 37a725c5..3140d407 100644 --- a/Tests/RCommon.Persistence.EFCore.Tests/EFCoreRepositoryIntegrationTests.cs +++ b/Tests/RCommon.Persistence.EFCore.Tests/EFCoreRepositoryIntegrationTests.cs @@ -748,5 +748,34 @@ public async Task Can_Eager_Load_Repository_And_Query_Async() Assert.That(savedCustomer.Orders.Count == 10); } + [Test] + public async Task Can_Eager_Load_Repository_And_Find_Async() + { + var testData = new List(); + + // Generate Test Data + var repo = new TestRepository(this.ServiceProvider); + repo.PersistSeedData(testData); + + var customer = TestDataActions.CreateCustomerStub(); + for (int i = 0; i < 10; i++) + { + var order = TestDataActions.CreateOrderStub(x => x.Customer = customer); + customer.Orders.Add(order); + testData.Add(customer); + } + repo.PersistSeedData(testData); + + var customerRepo = this.ServiceProvider.GetService>(); + customerRepo.Include(x => x.Orders); + var savedCustomer = await customerRepo + .FindAsync(customer.Id); + + Assert.That(savedCustomer != null); + Assert.That(savedCustomer.Id == customer.Id); + Assert.That(savedCustomer.Orders != null); + Assert.That(savedCustomer.Orders.Count == 10); + } + } }