What You Can Call a Provider for the Mocking IQueryable

I work with Moles and makes fun of System.Data.Linq.Table.

Everything worked out fine for me, but when I use it, it wants to be IQueryable. The provider also mocked him (moled).

I just want it to use regular Linq To Objects. Any idea what that would be?

Here is the syntax I can use:

MTable<User> userTable = new System.Data.Linq.Moles.MTable<User>(); userTable.Bind(new List<User> { UserObjectHelper.TestUser() }); // this is the line that needs help MolesDelegates.Func<IQueryProvider> provider = //Insert provider here! ^ userTable.ProviderSystemLinqIQueryableget = provider | | | what can I put here? ----------------------------------------+ 
+4
source share
2 answers

The simplest can be a List<T> , which can be used as an IQueryable<T> via .AsQueryable() .

 MolesDelegates.Func<IQueryProvider> provider = () => userLinqList.AsQueryable().Provider; 

This is what I use as the memory database for bullying Linq2Sql. Simple and elegant.

+7
source

A simple solution would be to bind list.AsQueryable () to a table. IQueryable methods will be automatically redirected to the list.

0
source

Source: https://habr.com/ru/post/1301021/


All Articles