repository-pattern

Repository and Unit of Work patterns - How to save changes

余生长醉 提交于 2019-12-03 02:55:09
问题 I'm struggling to understand the relationship between the Repository and Unit of Work patterns despite this kind of question being asked so many times. Essentially I still don't understand which part would save/commit data changes - the repository or the unit of work? Since every example I've seen relates to using these in conjunction with a database/OR mapper let's make a more interesting example - lets persist the data to the file system in data files; according to the patterns I should be

Repository pattern with Linq to SQL using IoC, Dependency Injection, Unit of Work

老子叫甜甜 提交于 2019-12-03 01:36:57
There seems to be lots of examples on implementing Repository pattern for Linq to SQL. Most of them featuring IRepository and DI; Some have implemented Unit of Work and some not. I tried to read as most of the results returned by searches on SO and Google on Linq to SQL repository patterns. Nevertheless I've not come across a complete solution yet. From my readings I've implemented a repository pattern as shown below: I'm using DI to register interfaces on which the repositories are depended: this.container.RegisterType<IConnectionStringFactory, ConnectionStringFactory>(new

MVC3 App/Service Layer/Repository Layer/POCO Classes/EF4 - Questions!

…衆ロ難τιáo~ 提交于 2019-12-03 01:31:20
问题 I am new to this whole design concept, and in reading for the last few weeks I have gathered a lot of information, but it seems scattered and conflicted. Terms are mixed, and I am just having a hard time wrapping my mind around this. The pattern I am using is like this and assume the flow as follows: MVC Application The controller(s) process the request/response from the client for a given view. Inside the controllers action methods, they contact the services (Service Layer) and either

Repository Pattern Best Practice

試著忘記壹切 提交于 2019-12-03 01:12:25
问题 So I'm implementing the repository pattern in an application and came across two "issues" in my understanding of the pattern: Querying - I've read responses that IQueryable should not be used when using repositories. However, it's obvious that you'd want to so that you are not returning a complete List of objects each time you call a method. Should it be implemented? If I have an IEnumerable method called List, what's the general "best practice" for an IQueryable? What parameters should

Repository pattern - Why exactly do we need Interfaces?

心不动则不痛 提交于 2019-12-03 01:02:41
问题 I have read from internet I got this points which says Interfaces is used for this Use TDD methods Replace persistance engine But I'm not able to understand how interface will be usefull to this point Replace persistance engine . lets consider I'm creating a basic(without generics) repository for EmployeeRepository public class EmployeeRepository { public employee[] GetAll() { //here I'll return from dbContext or ObjectContex class } } So how interfaces come into picture? and if suppose i

Repository Pattern Standardization of methods

怎甘沉沦 提交于 2019-12-03 00:53:37
问题 All I am trying to find out the correct definition of the repository pattern. My original understanding was this (extremely dumbed down) Separate your Business Objects from your Data Objects Standardize access methods in data access layer. I have really seen 2 different implementation, and there are no formal examples online, the ones i have seen are tucked away in books. Implementation 1 : public Interface IRepository<T>{ List<T> GetAll(); void Create(T p); void Update(T p); } public

Why use Repository Pattern or please explain it to me?

佐手、 提交于 2019-12-03 00:53:05
问题 I am learning repository pattern and was reading Repository Pattern with Entity Framework 4.1 and Code First and Generic Repository Pattern - Entity Framework, ASP.NET MVC and Unit Testing Triangle about how they implement the repository pattern with Entity Framework. Saying •Hide EF from upper layer •Make code better testable Make code better testable I do understand, but why hide EF from upper layer? Looking at their implementation, it seems just wrap the entity framework with a generic

Multiple Git repositories for each Eclipse project or one Git repository

China☆狼群 提交于 2019-12-03 00:42:20
问题 I am in the process of moving to Git from SVN. In SVN I had multiple eclipse projects in a single SVN repository that is convenient for browsing projects. I was going to move to having one git repository per eclipse project but EGit suggests doing otherwise. The guide for EGit suggests putting multiple projects into a single Git repository. Looking at similar questions such as this suggest one project per repository. Which approach is best practice and what do people implement? 回答1: It

Service Layers and Repositories

不打扰是莪最后的温柔 提交于 2019-12-03 00:10:37
问题 I've been using MVC frameworks for a short while now and I really like how the concerns are separated out. I've got into a bad habit of letting the controllers do quite a bit of work. So I'm really looking for some advice. When I first started using MVC I quite often had the controller doing manipulation on the models after database work had been done. I knew this was bad so moved that work into the models. However I'm not happy with that as I want my models to be very learn. I've done a bit

Where should I create the Unit of Work instance in an ASP.Net MVC 3 application?

泄露秘密 提交于 2019-12-02 23:32:23
I have read as many of the posts on Stackoverflow as I can find with regards the use of a Unit of Work pattern within an ASP.Net MVC 3 application which includes a Business Layer. However, I still have a couple of questions with regards this topic and would greatly appreciate any feedback people can give me. I am developing an ASP.Net MVC 3 Web application which uses EF 4.1. I will be using both the Repository and Unit of Work Patterns with this project similar to how they are used in this great tutorial The difference in my project is that I need to also include a Business Layer (separate