Thursday, April 12, 2018

repository pattern - should it contain a list/collection of entities in memory

For repository pattern, is it a good/bad idea to have a list/collection of entities as member variable that the methods act upon.

Below is high level logic ex. of one way vs the other. What reason(s) would you choose one over the other?

class ProductRepository { List<Product> productList;

public List<Product> GetProducts() { return productList; } 

}

vs

class ProductRepository { public List<Product> GetProducts() { return dbContext.Product.Query(); } }

repository pattern - should it contain a list/collection of entities in memory Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team