Awkward Generic Repository Call I am implementing a generic repository pattern. I have done this quite a few times now but every time I do it there is something bugging me. 

If I have a database design like below. (All the tables relate to one another.) 
And I make a call like the following:

public IEnumerable&lt;Domain&gt; GetRealEstate()
{
     return _repository.GetAll();
}




I can get all the models from just that one call (The wonders of EF). The thing that bugs me is the fact that I have to say Domain in the method call, from the domain entity I will get all the relevant entity (Lazy loading) Companies etc. etc. It just feels wrong to use domain entity to get all the companies etc. etc. The repo pattern that I am using is a straight forward one.

Is there a better way of writing the methods so that it does not look so weird?

Controller
RealEstateController

[RoutePrefix("api/realestate")]
    public class RealEstateController : ApiController
    {
        private readonly IRealEstateService _service;

        public RealEstateController(IRealEstateService service)
        {
            _service = service;
        }

        [Route("")]
        public Task&lt;Domain&gt; GetRealEstates()
        {
            var collection =  _service.GetRealEstate();
            return null;
        }

        [Route("{domainName}")]
        public Task&lt;Domain&gt; GetRealEstate(string domainName)
        {

        }
    }


Service

public class RealEstateService : IRealEstateService
    {
        private readonly IRealEstateRepository _repository;
        public RealEstateService(IRealEstateRepository repository)
        {
            _repository = repository;
        }
        public IEnumerable&lt;Domain&gt; GetRealEstate()
        {
            return _repository.GetAll();
        }
    }
I know this is not 100% spot on, but you should be able to take something from it and apply it in your own repository.

Here's a piece of code I use for one of my EF repositories, which I find very useful. I use a lot of Razor templating which won't lazy-load entities, so whenever I need to eagerly-load, I just include whatever relational entities I need before passing it to razor.

    public IQueryable&lt;T&gt; FindByInclude&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; predicate, params Expression&lt;Func&lt;T, object&gt;&gt;[] include) where T : class
    {
        IQueryable&lt;T&gt; query = _context.Set&lt;T&gt;().Where(predicate);

        foreach (var item in include)
        {
            query = query.Include(item);
        }

        return query;
    }


Example:

var user = Repo.FindByInclude&lt;User&gt;(z=&gt;z.Name = "Joachim Nordvik", "Address","Properties.Extended");


Now both the Address relation and Properties.Extended relations are eagerly loaded.