Quantcast
Channel: entityframework Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1793

New Post: Mocking DbSet throws ArgumentNullException for 'source' argument when used with Include

$
0
0
Roger, I disagree with your definition of the repository pattern. I don't believe you inherently break away from using repository pattern simply by allowing deferred queries.

I do, agree that using .Include ties you to Entity Framework; however, if it's not a Repository pattern in the traditional sense, it is still an offshoot of the Repository pattern. Frankly, if I was that concerned that the data access may actually change, I would lean a lot more towards your viewpoint. When is the last time you have needed to change data access frameworks in production code? I tend to not use .Include() regardless... I was just offering a solution to the original problem.

FuriCuri was having a problem mocking DbSet when using .Include, so I offered a solution:
Business logic relying on IRepository<T> is a lot easier to mock.

Call it a Repository pattern or something else, but it's certainly a valid approach to data access. I will always be willing to leak a little bit of the underlying data access (i.e. IQueryable.Include) if it gains me a much more centralized implementation and seriously simplifies unit test arrangement.

Viewing all articles
Browse latest Browse all 1793

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>