repository-pattern

It's not possible to lock a mongodb document. What if I need to?

六眼飞鱼酱① 提交于 2019-12-18 10:49:29
问题 I know that I can't lock a single mongodb document, in fact there is no way to lock a collection either. However, I've got this scenario, where I think I need some way to prevent more than one thread (or process, it's not important) from modifying a document. Here's my scenario. I have a collection that contains object of type A. I have some code that retrieve a document of type A, add an element in an array that is a property of the document ( a.arr.add(new Thing() ) and then save back the

Books that will cover TDD, DDD and Design Patterns in .NET

岁酱吖の 提交于 2019-12-18 10:19:30
问题 I would like to get book(s) that will really give me a complete view of modern ASP.NET development using C#, TDD, ASP.NET MVC, DDD and Design Patterns such as the Repository pattern. I'm very competent with C# and ASP.NET MVC, but want to fill in the gaps. If you've had a good experience with a book or two that covers these topics could you please share them? 回答1: I'm currently interested in how to architecture good .NET applications and I'm reading or have currently read some of the

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

坚强是说给别人听的谎言 提交于 2019-12-18 09:56:43
问题 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

DDD - persisting aggregate children only if changed

六眼飞鱼酱① 提交于 2019-12-18 08:28:21
问题 I'm trying use DDD in an application I'm currently working on. I have a following UserAggregate structure: UserAggregate - ProfileEntity - ImageEntity - RatingEntity And i have a UserRepository which is querying entities mappers to build a UserAggregate. Now I'd like to pass the UserAggregate to the UserRepository for persistance, like UserRepository->save(UserAggregate) . How do I tell the UserRepository that UserAggregate children entities have changed and needs to be saved? Is there any

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

可紊 提交于 2019-12-18 04:48:17
问题 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

Implementation example for Repository pattern with Linq to Sql and C#

﹥>﹥吖頭↗ 提交于 2019-12-18 02:42:44
问题 I am looking for a Repository pattern implementation example/resource that follows domain driven design principles for my ASP.net MVC application. Does anyone have a good example or learning resource that can be shared? 回答1: It's not an uncontroversial implementation, but Rob Conery's web storefront project has implemented repository via Linq to Sql in C#. http://blog.wekeroad.com/ Source is available. He's not quite doing strict DDD, but his TDD is generally sending him out in that direction

Generic repository to update an entire aggregate

血红的双手。 提交于 2019-12-17 22:51:37
问题 I am using the repository pattern to provide access to and saving of my aggregates. The problem is the updating of aggregates which consist of a relationship of entities. For example, take the Order and OrderItem relationship. The aggregate root is Order which manages its own OrderItem collection. An OrderRepository would thus be responsible for updating the whole aggregate (there would be no OrderItemRepository ). Data persistence is handled using Entity Framework 6. Update repository method

Repository Pattern - How to understand it and how does it work with “complex” entities?

孤者浪人 提交于 2019-12-17 21:25:41
问题 I'm having a hard time understanding the Repository Pattern. There are a lot of opinions on that topic like in Repository pattern done right but also other stuff like Repository is the new Singleton or again like in Don't use DAO use Repository or just take Spring JPA Data + Hibernate + MySQL + MAVEN where somehow a Repository appears to be the same as a DAO object. I'm getting tired of reading this stuff since imho this can't be such a hard thing as it is displayed in a lot of articles. I

Using Unity, how do you register type mappings for generics?

ぐ巨炮叔叔 提交于 2019-12-17 20:19:03
问题 I'm trying to implement a repository solution for Entity Framework but I am having trouble registering the types that include generics using Unity. Given: // IRepository interface public interface IRepository<TEntity> { // omitted for brevity } // Repository implementation public class Repository<TEntity, TContext> : IRepository<TEntity>, IDisposable where TEntity : class where TContext : DbContext { // omitted for brevity } // service layer constructor public MyServiceConstructor(IRepository

Readonly properties in EF 4.1

泄露秘密 提交于 2019-12-17 17:46:15
问题 I've faced with situation when I need to have EF readonly property in case of 'optimistic update'(you do not load current state of your domain object from database to check what properties are really changed. You just set your object as Modified and update it to database. You avoid redundant select and merge operations in this case). You can't write something like this : DataContext.Entry(entity).Property(propertyName).IsModified = false; , because setting of 'false' value is not supported