repository-pattern

Need a simple example of using nhibernate + unit of work + repository pattern + service layer + ninject

本小妞迷上赌 提交于 2019-11-30 10:40:01
问题 I am using nhibernate + fluent nhibernate asp.net mvc 3 ninject Currently I am using nhibernate, ninject with the repository pattern and service layers. So I have this ninject public class NhibernateSessionFactory { public ISessionFactory GetSessionFactory() { ISessionFactory fluentConfiguration = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("ConnectionString"))) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Framework.Data

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

点点圈 提交于 2019-11-30 10:10:14
问题 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) //

What type is repository pattern in?

与世无争的帅哥 提交于 2019-11-30 09:01:04
In general, I know that there are 3 big types of design pattern Creational Pattern (Factory, Singleton, etc) Structural Pattern (Composite, Adapter, Proxy, etc) Behavioral Pattern (Specification, Command, etc) But I dont know which type I can put the Repository pattern in. Is Repository pattern in one of three above type? Or is it kind of in the middle of (2) and (3) pattern? Repository can be viewed as a special kind of Façade (structural) but also as a special kind of Factory (creational). Also, as the Repository often expose collection-like interface, then it might be a special application

Issues with my MVC repository pattern and StructureMap

浪尽此生 提交于 2019-11-30 07:47:13
I have a repository pattern i created on top of the ado.net entity framework. When i tried to implement StructureMap to decouple my objects, i kept getting StackOverflowException (infinite loop?). Here is what the pattern looks like: IEntityRepository where TEntity : class Defines basic CRUD members MyEntityRepository : IEntityRepository Implements CRUD members IEntityService where TEntity : class Defines CRUD members which return common types for each member. MyEntityService : IEntityService Uses the repository to retrieve data and return a common type as a result (IList, bool and etc) The

How should I structure a simple ASP.NET MVC app?

女生的网名这么多〃 提交于 2019-11-30 07:03:53
I've been reading a few things about ASP.NET MVC, SOLID and so on, and I am trying to figure out a simple "recipe" for small-to-medium ASP.NET MVC apps that would put these concepts together; the issue that I am most concerned with is ending up with controllers that are too complex and being like code-behind files in webforms, with all type of business logic into them. I am considering the following architecture, for a small data-driven app: Controllers: only handle requests, call an appropriate service and return the action result to the View; Models: POCO, handle all the business logic,

Laravel - Using the Repository Pattern

末鹿安然 提交于 2019-11-30 06:57:31
I am trying to learn the repository pattern, and seem to have got myself a tad confused with how I can use this repository pattern when eager loading relationships and keep db logic out of my controller. A quick overview of my repository / application structure. app/ Acme/ Repositories/ RepositoryServiceProvider.php Product/ EloquentProduct.php ProductInterface.php Category/ EloquentCategory.php CategoryInterface.php Example ProductInterface.php <?php namespace GD\Repositories\Product; interface ProductInterface { public function all(); public function find($id); public function findBySlug(

ASP.NET MVC, Ninject, single instance per request for multiple constructors

不想你离开。 提交于 2019-11-30 06:26:09
Im trying to implement an unit of work pattern by passing an unit of work instance into my repositories. Relevant code from Global.asax. public class SiteModule : NinjectModule { public override void Load() { Bind<IUnitOfWork>().To<SqlUnitOfWork>() .InRequestScope() .WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["Entities"].ConnectionString); Bind<IProductRepository>().To<ProductRepository>(); Bind<ICategoryRepository>().To<CategoryRepository>(); } } Repository constructors: public class ProductRepository { IUnitOfWork unitOfWork; public ProductRepository

Is there a reason for using the Repository pattern with Entity Framework if I know I will only ever use EF?

青春壹個敷衍的年華 提交于 2019-11-30 06:22:41
From reading various books and articles, I seem to rather often find the usage of the Repository-pattern suggested. I get the point if you need to be able to swap out your data layer from one to another, but my question is, if I know with 100% certainty that I will not use any other tech for data access, is there any reason for using said pattern? The thing that I find myself doubting the most is that I don't really see what this extra layer of abstraction can bring to the table in this scenario. From my experience, EF with its fluent linq-to-entities -functionality should be more than enough

entity framework + repository + unit or work question

耗尽温柔 提交于 2019-11-30 05:27:52
I'm thinking about starting a new project using EF 4 and going through some articles, I found an article about EF with repository pattern and unit of work ( http://blogs.msdn.com/b/adonet/archive/2009/06/16/using-repository-and-unit-of-work-patterns-with-entity-framework-4-0.aspx ) Looking at that article, it uses the ObjectContext as the UnitOfWork and it passes it to the Repository. My question is what if I have 2 ObjectContext which mean I will have 2 unit of work, but I actually wants all the operation perform on those 2 context to be one single unit of work, is this scenario possible? I

MVC repository pattern design decision

柔情痞子 提交于 2019-11-30 05:17:02
I have an asp .net MVC application and recently started implementing the repository pattern with a service validation layer, much like this . I've been creating one repository/service for each model that I create. Is this overkill? Instead, should I create one repository/service for each logical business area that provides CRUD for many different models? To me, it seems like I'm either cluttering the project tree with many files or cluttering a class with many methods. 6 one way half dozen the other. Can you think of any good arguments either way? Generally, if you're using a "true" Repository