Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Isolate.WhenCalled(() => fakeContext.Context.CreateObjectSet<User>)).WillReturnCollectionValuesOf(fakeUsers.AsQueryable());
- public static IQueryable<T> Include<T>(this IQueryable<T> source, Expression<Func<T>> property)
- {
- var objectQuery = source as ObjectQuery<T>;
- if (objectQuery != null)
- {
- var propertyPath = GetPropertyPath(property);
- return objectQuery.Include(propertyPath);
- }
- return source;
- }
- public interface IMyObjectQuery<T> : IOrderedQueryable<T>
- {
- IMyObjectQuery<T> Include(string path);
- }
- public class MyObjectQuery<T> : IMyObjectQuery<T>
- {
- private ObjectQuery<T> _query;
- public MyObjectQuery(ObjectQuery<T> query)
- {
- _query = query;
- }
- IMyObjectQuery<T> Include(string path)
- {
- //There is probably a better way to do this
- //but you get the idea
- return new MyObjectQuery(_query.Include(path));
- }
- //Implement IQueryable, IEnumerable...
- }
- public class MyRepository : IMyRespository
- {
- ...
- public IMyObjectQuery<T> CreateQuery<T>()
- {
- return new MyObjectQuery(_context.CreateQuery<T>());
- }
- ...
- }
Add Comment
Please, Sign In to add comment