ddd-repositories

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

Aggregates, Transactional Consistency and the Entity Framework DbContext

こ雲淡風輕ζ 提交于 2019-12-18 13:34:51
问题 Aggregates must be designed to be transactionally and eventually consistency. This consistency boundary around entities helps manage complexity. In our repository implementations, we are using Entity Framework to interface with the actual database. Historically we have always had huge contexts (spanning scores of tables) which represent every available table, field and relationship in the database (or at least in some functional area of the database). The problem here is that this context is

Is it ok for entities to access repositories?

不问归期 提交于 2019-12-17 03:16:57
问题 I've just started working with DDD, so maybe this is a silly question... Is it ok for an entity to access a repository (via some IRepository interface) to get a value at runtime? For example, I want to enforce a "default" selection for a property: class Person { private Company _employer; public Company Employer { get { return _employer; } set { if(value != null) { _employer = value; } else { _employer = employerRepository.GetDefaultEmployer(); } } } ... } My question is whehter doing

DDD: How to handle large collections

醉酒当歌 提交于 2019-12-13 13:08:06
问题 I'm currently designing a backend for a social networking-related application in REST. I'm very intrigued by the DDD principle. Now let's assume I have a User object who has a Collection of Friends. These can be thousands if the app and the user would become very successful. Every Friend would have some properties as well, it is basically a User. Looking at the DDD Cargo application example, the fully expanded Cargo-object is stored and retrieved from the CargoRepository from time to time.

How to avoid aggregate being dependent on outside includes?

帅比萌擦擦* 提交于 2019-12-13 04:17:49
问题 I do not use lazy loading. My root aggregate have entities (collection navigation properties). I want my aggregate to be self-contained, responsible for itself, and follow the Single Responsibility Principle (SRP), and adhere to high cohesion and low coupling. The problem is that the code that retrieves the root aggregate needs to include certain child entities depending on which way it wants to interact with the aggregate. Example: public class Blog // My root aggregate { public ICollection

Repository EF DBContext

牧云@^-^@ 提交于 2019-12-12 02:33:36
问题 my question is a two part issue. I am using the repository and unit of work pattern with entity framework. I have the following StockTransferRepository and StockTransfer is my aggregateRoot. Public Class StockTransferRepository Inherits WMSBaseRepository(Of StockTransfer, Int64, Dictionary(Of String, String)) Implements IStockTransferRepository Public Sub New(uow As IUnitOfWork) MyBase.New(uow) End Sub Public Overrides Function GetObjectSet() As IQueryable(Of StockTransfer) Return

Different persistence repositories for an aggregate in DDD

蓝咒 提交于 2019-12-11 01:45:53
问题 I have an aggregate with a root entity (Documentation) and a VO (Document). Documents are associated with files (pdfs, images, office documents, etc), so I have to persist the aggregate in a database and files in a ftp server (files cannot be saved in the database because space files is too large). My db repository class implements an interface with methods like FindXXX, AddDocument, RemoveDocument and others. How could I implement ftp persistence? Should my db repository connect to ftp

Identity conflict in DDD with Repository

断了今生、忘了曾经 提交于 2019-12-11 00:46:47
问题 I'm following a database first approach in a sample app. The POCO classes are generated via t4 template and it will have the Identity properties that it carry from the database. For some classes which I use as entities in the domain, the type of the id can be int, string & Guid . I don't see a problem with ids that are string or Guid which I can generate in the domain and pass that to the repository. In the case of int also I can do that, but I want to take advantage of the AUTOINCREMENT

Nhibernate - One-to-one mapping with Cascade all-delete-orphan, not deleting the orphan

ぐ巨炮叔叔 提交于 2019-12-10 14:45:43
问题 I have an 'Interview' entity that has a one-to-one mapping with a 'FormSubmission' entity, the Interview entity is the dominant side so to speak, the mapping is: <class name="Interview"> <id name="Id" column="Id" type="Int64"> <generator class="identity" /> </id> // other props (snip).... <one-to-one name="Submission" class="FormSubmission" cascade="all-delete-orphan" /> </class> <class name="FormSubmission"> <id name="Id" column="Id" type="Int64"> <generator class="foreign"> <param name=

nhibernate, could not resolve property QueryOver only one table

夙愿已清 提交于 2019-12-10 14:14:29
问题 I have found a dozen of question similar to mine but none of them offered a solution to my problem. Thank you in advance Ok, I have this class public class User : IEntity { private int id; public virtual int Id { get { return id; } } private string email; public virtual string Email { get { return email; } //private set { email = value; } } private string password; public virtual string Password { get { return password; } //private set { password = value; } } private bool isActive; public