1

I am using a View in EntityFramework Core through something like

modelBuilder.Query<DeviceHierarchy>().ToView("DeviceHierarchy");

I tried to use the solution from this question to mock the view.

The view is used in a join like this

Context.Devices.Where(...).Join(Context.DeviceHierarchy, ...)

but I got an exception and can not figure out what's the problem

at System.Linq.Lookup`2.CreateForJoin(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.JoinIterator[TOuter,TInner,TKey,TResult](IEnumerable`1 outer, IEnumerable`1 inner, Func`2 outerKeySelector, Func`2 innerKeySelector, Func`3 resultSelector, IEqualityComparer`1 comparer)+MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.Max(IEnumerable`1 source)
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ResultEnumerable`1.GetEnumerator()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
at System.Linq.AsyncEnumerable.AsyncEnumerableAdapter`1.MoveNextCore(CancellationToken cancellationToken)
at System.Linq.AsyncEnumerable.AsyncIterator`1.MoveNext(CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteSingletonAsyncQuery[TResult](QueryContext queryContext, Func`2 compiledQuery, IDiagnosticsLogger`1 logger, Type contextType)

Can a view be mocked using Microsoft.EntityFrameworkCore.InMemory package?

Dan
  • 683
  • 2
  • 8
  • 24
  • Are you working with repository pattern? – H. Herzl Nov 02 '18 at 06:14
  • Since I am using a join then no. Also I do not see the relevance since I would still want a join to be done on the database and not in memory. – Dan Nov 02 '18 at 07:10

0 Answers0