I was looking at the repository method for an ASP.NET MVC app and noticed a static class wasn’t used.
Since the repo is CRUD, why not make it static?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1) It’s difficult to do unit testing with static classes (if you are testing a class that depends on your repository, you want that test to work against a fake ‘mocked’ repository object instead of your real one)
2) You often want to have 1 repository instance per-request to make it easier to ensure that uncommited changes from one user don’t mess things up for another user.