repository-pattern

What type is repository pattern in?

心已入冬 提交于 2019-11-29 12:45:05
问题 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? 回答1: Repository can be viewed as a special kind of Façade (structural) but also as a special kind of Factory

Laravel - Using the Repository Pattern

限于喜欢 提交于 2019-11-29 09:25:44
问题 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;

Implementing Repository pattern and doing Tests

三世轮回 提交于 2019-11-29 08:47:04
I have read almost all articles about Repository pattern and different implementations of it. Many of them judged bad practices (ex: using IQueryable<T> instead of IList<T> ) etc. that why i'm still stuck and couldn't end-up to the right one. So: Do I need Repository pattern to apply IoC in my MVVM applications ? If yes, What is the efficient IRepository implementation to EF Entities which is a good practice and better testable ? How can I test my Repositories and UnitofWork behavior ? Unit tests against in memory Repositories ? Integration tests ? Edit : According to answers I added the first

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

大憨熊 提交于 2019-11-29 08:26:19
问题 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

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

随声附和 提交于 2019-11-29 06:11:46
问题 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>(); } }

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

ⅰ亾dé卋堺 提交于 2019-11-29 06:10:38
问题 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

EF - and repository pattern - multiple contexts

≯℡__Kan透↙ 提交于 2019-11-29 05:17:12
I've faced some troubles with context in EF in ASP.MVC2. I thought that best way to improve some operation on DataBase i've created Repository. My repo class adds, deletes, select many items so i don't need to write (using <name>Context = new (... etc ...) ) { ... } Repository eliminates initializing context for every operation, but don't dispose the context. What is the best way to manage contexts? If i create other repository class and try to do any operation which will need objects from both contexts there is a problem. Is there any other way or better way to implement repository, to manage

entity framework + repository + unit or work question

青春壹個敷衍的年華 提交于 2019-11-29 05:15:23
问题 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

Using The Repository Pattern, Is It Best To Save Parent and Children Objects Together Or Separately?

喜你入骨 提交于 2019-11-29 04:48:41
Having a parent object Employee with a list of Address child objects: class Employee { List<Address> addresses; } and a Repository method: void Insert(Employee); Should the code within this repository attempt to save the parent Employee as well as the child Address objects, or should separate repositories handle the parent and children objects? If separate repositories, then when saving the Employee object and its children within the client code, should this be separate calls at that level, combined in some sort of service or is there another alternative? The repository should handle the

Should A repository call another repository? Or should a repository call a service layer?

末鹿安然 提交于 2019-11-29 04:22:06
I am trying to figure out how to tackle this problem. I have to insert some data into 2 tables lets call them Table A and Table B. Table A has these columns AId<PK> A1 A2 A3 Table B has AId<PK> A1 B2 B3 B4 Now my first question was should another repository call another repository? I don't think this will solve my current problem but I just want to know this for future reference? Now onto my problem. when I call a create in my repository layer(TableARepository) to Create Table A. I create right away the fields for tableB too. // linq to sql. TableA myATable = new TableA(); dbContext.myATable