@hikalkan thanks!
I have watched your presentation a few time before. (You do a great job of explaining things in that presentation!) To be honest I didn't relazie the navigation properties in ABP Suite were actaully creating an EF naviagation property. I thought it was only creating and storing the Id. I used the Naviation Properties in ABP Suite simply for the modal picker. :)
So we really shouldn't ever use the ABP Suite Navigation Properties if we what to follow the DDD best practice. Right?
All we really wanted from the begining was to stort Guid Ids.
Is this approch OK? Use ABP Suite to create the properties for the Id's, and then manaully add HasIndex(), and then the FK into the generated migration?
Where can I find an example of adding a modal Picker for an Id field similar to the one that ABP Suite creates when you choose Modal in the NP UI? I've looked in the EasyCRM project but I don't see an example of a Modal picker.
Thanks guys!
@hikalkan, I am fairly new to DDD so please forgive me for my lack of knowledge. If a navigation properties to the AppUser is not good practice, then what is a best practice for this use case in DDD? Is there a better way to utilize the existing system user? I don't think creating and maintaining multiple user entities is very practical.
@hikalkan, I am trying to ignore the AppUser ExtraProperties, but I'm still receiving this error. I think, it's because the Ticket entity has a navigation link to a AppUser.
However, I cannot ignore the ExtraProperties in the Dto CreateMap<Ticket, TicketDto>().Ignore(x => x.Assignee.ExtraProperties);
because x (TicketDto) does not contain Assignee.
@alpher,
I followed your previous instructions, however when I try to add a migration I get the following error. I think I need to somehow ignore the ExtraProperties for the navigation LookupDtos.
@Alper,
I created the following files based on the Gist you created. I'm assuming all of them with exception to EfCoreSequentialNumberRepository
belong in the Domain project.
I guess the next step is to add the following DBContext items create and delplay a new migration.
SupportDbContext.cs
public DbSet<SequentialNumber> SequentialNumbers { get; set; }
SupportDbContextModelCreatingExtensions.cs
builder.Entity<SequentialNumber>(b =>
{
b.ToTable(SupportConsts.DbTablePrefix + "SequentialNumbers", SupportConsts.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.TenantId).HasColumnName(nameof(SequentialNumber.TenantId));
b.Property(x => x.SequenceName).HasColumnName(nameof(SequentialNumber.SequenceName)).IsRequired();
b.Property(x => x.CurrentValue).HasColumnName(nameof(SequentialNumber.CurrentValue)).IsRequired();
b.HasIndex(x => new { x.TenantId, x.SequenceName }).IsUnique().HasFilter(null);
});
Since Domain services (implement IDomainService interface) are registered as transient automatically the next step is to inject an ISequentialNumberManager into the CreateModal.
private readonly ISequentialNumberManager _sequentialNumberManager;
public CreateModalModel(ITicketAppService ticketAppService, ISequentialNumberManager sequentialNumberManager)
{
_tagAppService = ticketAppService;
_sequentialNumberManager = sequentialNumberManager;
}
Finally, we set the Ticket.Number in OnPostAsync()
prior to posting.
public async Task<IActionResult> OnPostAsync()
{
Ticket.Number = await _sequentialNumberManager.GetNextAsync("Ticket");
await _tagAppService.CreateAsync(Ticket);
return NoContent();
}
Thanks for your amazing support on this one @Alper!
@alper thanks! This helps a lot! I was thinking a domain service was more complicated.
@alper, it appears that @hikalkan has plans to provide documentation, and probably examples for domain services. I'm not sure why these questions would be out of context. Maybe a full working example is out of context, but I'm not sure where I'd find basic coding example for creating ABP domain services on the internet. I'll admit you guys are very smart and what seems basic to you may not be basic to us ABP newbies. Furthermore, we are willing to pay for professional services if that is required. Would you please have someone help us with this or send us a quote for professional services?
@alper,
Can you please elaborate on your previeous SequentialNumberRepository post, and provide a working example? I'm sure this example would be useful for others, and I'll also include and expalin this techneqe in the Acme.HelpDesk tutorial.
How would you wire this up to a specific entity property Ticket.Number
(i.e. javascript
, code-behind
)
How would you handle the case when the entity insert fails? Would you simply skip that seq #, or should the SequentialNumberRepository
provide a Decrement()
method for this case? I'd vote for simply skipping that seq #, because providing a Decrement()
option opens a whole new set of potential issues/problems.
Finally, is it okay to make the target property an index field to ensure it's unique? (i.e. b.HasIndex(x => new {x.TenantId , x.Number}).IsUnique(true);
)