repository-pattern

Is Unit Of Work and Repository Patterns very useful for big projects?

断了今生、忘了曾经 提交于 2019-11-29 20:11:33
I'm starting a new web project using ASP.NET Webforms + EF4. I'm trying to apply a repository pattern with a unit of work pattern following this tutorial : http://www.dotnetage.com/publishing/home/2011/07/05/6883/the-repository-pattern-with-ef-code-first-dependeny-injection-in-asp-net-mvc3.html I think I got the idea but my question is that, when I create a new object in the model, do I also have to define that object in IDALContext of the Unit Of Work? Isn't that a handbreak for rapid development? Also if you work with multiple developers and if you don't want other developers to see your DAL

Generating identities for entities in DDD

早过忘川 提交于 2019-11-29 19:06:17
问题 Edit To further clarify my initial problem, I rewrote the question with more 'DDD'-termini, common patterns and discussion arguments. The orginal version can be found under revisions. Where and how are identities for entities / aggregate roots being generated inside the domain when correctly applying DDD? I need to assign unique identities to my entities, either upon creation or persisting. Those identities can come in several styles Computed (based on the characteristics of an entity, hence

Unit of Work + Repository Pattern: The Fall of the Business Transaction Concept

孤者浪人 提交于 2019-11-29 18:56:49
Combining Unit of Work and Repository Pattern is something used fairly widely nowadays. As Martin Fowler says a purpose of using UoW is to form a Business Transaction while being ignorant of how repositories actually work (being persistent ignorant). I've reviewed many implementations; and ignoring specific details (concrete/abstract class, interface,...) they are more or less similar to what follows: public class RepositoryBase<T> { private UoW _uow; public RepositoryBase(UoW uow) // injecting UoW instance via constructor { _uow = uow; } public void Add(T entity) { // Add logic here } //

ASP.NET MVC with service layer and repository layer, where should the interfaces be defined?

家住魔仙堡 提交于 2019-11-29 18:53:30
I am in the process of determining a fairly simple layered architecture for a .NET MVC application that has a repository layer and a service layer. I have found some fairly clear and simple examples, notably www.asp.net , and some questions and answers here, but I am looking for something that is a little simpler, suitable for small applications, but that uses different projects, to get the idea across. The example I linked to above has the repository and service as classes in the Models namespace. That just isn't enough of a clear separation for me to be able to illustrate it properly. I have

Well designed query commands and/or specifications

南楼画角 提交于 2019-11-29 18:35:17
I've been searching for quite some time for a good solution to the problems presented by the typical Repository pattern (growing list of methods for specialized queries, etc.. see: http://ayende.com/blog/3955/repository-is-the-new-singleton ). I really like the idea of using Command queries, particularly through use of the Specification pattern. However, my problem with specification is that it only relates to the criteria of simple selections (basically, the where clause), and does not deal with the other issues of queries, such as joining, grouping, subset selection or projection, etc..

Managing relationships in Laravel, adhering to the repository pattern

北城以北 提交于 2019-11-29 18:32:28
While creating an app in Laravel 4 after reading T. Otwell's book on good design patterns in Laravel I found myself creating repositories for every table on the application. I ended up with the following table structure: Students: id, name Courses: id, name, teacher_id Teachers: id, name Assignments: id, name, course_id Scores (acts as a pivot between students and assignments): student_id, assignment_id, scores I have repository classes with find, create, update and delete methods for all of these tables. Each repository has an Eloquent model which interacts with the database. Relationships

Best practices of implementing unit of work and repository pattern using ServiceStack.ORMLite

☆樱花仙子☆ 提交于 2019-11-29 17:54:36
问题 Supposing that there are two repository interface : interface IFooRepository { void Delete(int id); } interface IBarRepository { void Delete(int id); } And an IUnitOfWork interface like : interface IUnitOfWork : IDisposable { void Commit(); void Rollback(); } what is the best practices of implementing those interface using ServiceStack.ORMLite so that user can use them like MyFooRepository.Delete(4); // if an Exception throws here, Bar won't be deleted MyBarRepository.Delete(7); Or using (var

Appropriate lifecycle for repository classes using Castle Windsor

微笑、不失礼 提交于 2019-11-29 16:01:16
When I started with Windsor I thought DI would be simple. Now it's causing me more and more confusion. A repository strikes me as a class with a singleton lifecycle. I should have a single instance of a FooRepository to load and save Foos to the database during the application's lifetime. However, each repository holds a reference to a UnitOfWork, which does the dirty checking, works with the database etc. The UnitOfWork has a lifecycle of PerWebRequest - it makes no sense at all for the UnitOfWork to be a singleton, as a singleton instance could (for example) flush the changes made by several

Cannot seem to moq EF CodeFirst 4.1.Help anyone?

走远了吗. 提交于 2019-11-29 15:43:46
问题 I have been given the task to evaluate codeFirst and possible to use for all our future projects. The evaluation is based on using codeFirst with an existing database. Wondering if it's possible to mock the repository using codeFirst 4.1.(no fakes) The idea is to inject a repository into a service and moq the repository. I have been looking on the net but I have only found an example using fakes.I dont want to use fakes I want to use moq. I think my problem is in the architecture of the DAL.

Dependency Injection

与世无争的帅哥 提交于 2019-11-29 15:40:21
We are builing a windows desktop application (not web based) and trying to come up with the best way to implement Repository and UnitOfWork Pattern. In a typical Asp.Net Mvc application your repositories are injected with data context, services are injected with repositories and finally controllers are injected with services and all is well if you don't hit any exception, you will commit the changes. In windows forms/wpf applications it is not advisable to use single datacontext ( Oren has a post on this on MSDN) so we have decided to create data context at the presenter. We are using Linq2SQl