Examples of the official website start tutorial Abp is IRpositoty <entity> directly in the application layer. But if the will is an aggregate root that right? Well aggregate root access is the smallest unit of storage to operate the service through aggregate root, is an entity, then the entity additions and deletions to change search, it should be in aggregate root inside.
That there is a problem, inherited the aggregate root entity ,, he did not warehousing, how to save it?
Method One: dependency injection, this will not work, so that database migration was unsuccessful.
1 public class Order :AggregateRoot, IRepository<Order>, ICreationAudited 2 { 3 [NotMapped] 4 private IRepository<Order> _repository { get; set; } 5 public Order(IRepository<Order> repository) 6 { 7 _repository = repository; 8 } 9 public long? CreatorUserId { get; set; } 10 public DateTime CreationTime { get; set ; } 11 public List<OrderItem> OrderItem { get; set; } 12 public string Remark { get; set; } 13 public Address Address { get; set; } 14 15 public Order Insert(Order entity) 16 { 17 return entity; 18 } 19 }
public class Order :AggregateRoot, IRepository<Order>, ICreationAudited { public long? CreatorUserId { get; set; } public DateTime CreationTime { get; set ; } public List<OrderItem> OrderItem { get; set; } public string Remark { get; set; } public Address Address { get; set; } public Order Insert(Order entity) { return entity; } }
public class Test2 : Test2Repository, IAggregateRoot, ICreationAudited { public long? CreatorUserId { get; set; } public DateTime CreationTime { get; set; } public string Remark { get; set; } public ICollection<IEventData> DomainEvents => throw new NotImplementedException(); public int Id { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public bool IsTransient() { throw new NotImplementedException(); } }
So that the compiler is not the past, because EF Test2Repository in that layer, while the Core who is not dependent, at the bottom, this is not going to work.
Method four: this is the root of the polymer, and then implement a IOrder interfaces, storage interfaces, and this interface there is an overlap in the application layer, the exposed IOrder interfaces on the line.