Guest User

Untitled

a guest
Jul 20th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. Isolate.WhenCalled(() => fakeContext.Context.CreateObjectSet<User>)).WillReturnCollectionValuesOf(fakeUsers.AsQueryable());
  2.  
  3. public static IQueryable<T> Include<T>(this IQueryable<T> source, Expression<Func<T>> property)
  4. {
  5. var objectQuery = source as ObjectQuery<T>;
  6.  
  7. if (objectQuery != null)
  8. {
  9. var propertyPath = GetPropertyPath(property);
  10. return objectQuery.Include(propertyPath);
  11. }
  12.  
  13. return source;
  14. }
  15.  
  16. public interface IMyObjectQuery<T> : IOrderedQueryable<T>
  17. {
  18. IMyObjectQuery<T> Include(string path);
  19. }
  20.  
  21. public class MyObjectQuery<T> : IMyObjectQuery<T>
  22. {
  23. private ObjectQuery<T> _query;
  24.  
  25. public MyObjectQuery(ObjectQuery<T> query)
  26. {
  27. _query = query;
  28. }
  29.  
  30. IMyObjectQuery<T> Include(string path)
  31. {
  32. //There is probably a better way to do this
  33. //but you get the idea
  34. return new MyObjectQuery(_query.Include(path));
  35. }
  36.  
  37. //Implement IQueryable, IEnumerable...
  38. }
  39.  
  40. public class MyRepository : IMyRespository
  41. {
  42. ...
  43. public IMyObjectQuery<T> CreateQuery<T>()
  44. {
  45. return new MyObjectQuery(_context.CreateQuery<T>());
  46. }
  47. ...
  48. }
Add Comment
Please, Sign In to add comment