repository-pattern

Searching for a Child across Aggregate Roots

岁酱吖の 提交于 2019-12-19 10:32:48
问题 The repository pattern suggest that you can only pull aggregate roots. But how would you retrieve a single child using only it's uniqiue identity(Child.ID) if you do not know it's parent(root)? class Parent { public int ID { get; set; } IEnumerable<Child> Children { get; private set; } } class Child { public int ID { get; private set; } public virtual Parent Parent { get; private set; } // Navigational model } My application is stateless (web), for simplicity, the request only contains the ID

Linq to SQL and concurrency with Rob Conery repository pattern

自作多情 提交于 2019-12-19 09:53:53
问题 I have implemented a DAL using Rob Conery's spin on the repository pattern (from the MVC Storefront project) where I map database objects to domain objects using Linq and use Linq to SQL to actually get the data. This is all working wonderfully giving me the full control over the shape of my domain objects that I want, but I have hit a problem with concurrency that I thought I'd ask about here. I have concurrency working but the solution feels like it might be wrong (just one of those gitchy

Multiple DbContext classes for a single web app. Good or bad?

大兔子大兔子 提交于 2019-12-19 05:52:48
问题 Is it a good practice to have multiple XXX : DbContext classes for each major section of a web application (considering it's a big one with at least 50 tables in its database)? For example: MembershipContext, BlogContext, StoreContext etc. Or it's more convenient to have a single DatabaseContext for all the db access related stuff. 回答1: Using multiple DbContext classes implies complicating cross-transactions (you can find a solution to this problem on the web here an example http://pastebin

Confusion between DTOs (linq2sql) and Class objects!

做~自己de王妃 提交于 2019-12-18 16:59:33
问题 i have been successfully working with linq2sql and the linq DTOs (the classes that are created by linq2sql) .... I am confused, i have the task of updating an old application and i can see that my DTOs will be used how they should be .... to transport date I am using the repository pattern so i am passing data from the repository to the service via the linq2sql dtos... once i am in the service layer (this is basically my business logic) then I need to pass around class objects .. these class

Confusion between DTOs (linq2sql) and Class objects!

醉酒当歌 提交于 2019-12-18 16:59:02
问题 i have been successfully working with linq2sql and the linq DTOs (the classes that are created by linq2sql) .... I am confused, i have the task of updating an old application and i can see that my DTOs will be used how they should be .... to transport date I am using the repository pattern so i am passing data from the repository to the service via the linq2sql dtos... once i am in the service layer (this is basically my business logic) then I need to pass around class objects .. these class

How to implement generic GetById() where Id can be of various types

风格不统一 提交于 2019-12-18 12:22:30
问题 I am trying to implement a generic GetById(T id) method which will cater for types which may have differing ID types. In my example, I have an entity which has an ID of type int , and one of type string . However, I keep getting an error and I have no idea why: The type 'int' must be a reference type in order to use it as parameter 'TId' in the generic type of method IEntity Entity Interface: To cater for my domain models which can have Id's of type int or string . public interface IEntity

Updating records using a Repository Pattern with Entity Framework 6

删除回忆录丶 提交于 2019-12-18 12:22:04
问题 I'm writing a simple blog application and trying to establish CRUD operations in my generic repository pattern but I'm getting an error on my update method that says: 'System.Data.Entity.DbSet' does not contain a definition for 'Entry' and no extension method 'Entry' accepting a first argument of type 'System.Data.Entity.DbSet' could be found (are you missing a using directive or an assembly reference?) I followed a post that explained how to 'fake' Entry() by adding additional level of

MVC repository pattern design decision

一曲冷凌霜 提交于 2019-12-18 11:53:18
问题 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

Laravel 5 - Interface is not instantiable

坚强是说给别人听的谎言 提交于 2019-12-18 11:01:09
问题 I know that this question was asked so many times, but none of answers helped me. I'm getting exception in Laravel 5 BindingResolutionException in Container.php line 785: Target [App\Contracts\CustomModelInterface] is not instantiable. What I've done without success: Register App\Providers\AppRepositoryProvider in app.php providers php artisan clear-compiled Everything works if I replace interfaces on repositories in MyService, but I feel that it's wrong (should it be handled by IoC container

Laravel 5 - Interface is not instantiable

為{幸葍}努か 提交于 2019-12-18 11:01:06
问题 I know that this question was asked so many times, but none of answers helped me. I'm getting exception in Laravel 5 BindingResolutionException in Container.php line 785: Target [App\Contracts\CustomModelInterface] is not instantiable. What I've done without success: Register App\Providers\AppRepositoryProvider in app.php providers php artisan clear-compiled Everything works if I replace interfaces on repositories in MyService, but I feel that it's wrong (should it be handled by IoC container