Open Mike6x opened 1 year ago
In this github: https://github.com/Mike6x/CQRS_Ardalis_template
I have to controller:
Ok, it seems you're using AddRangeAsync
for both adding and updating records, right?
Did you try without using specs and repositories, and working directly with dbContext instead? It seems it's not about this library per se, but that's how the EF tracker works.
Hey @Mike6x,
Any update here?
I am using Ardalis 6.1.0 + MediatR in NET 6 CQRS Pattern and try new AddRangeAsync function. Everthing seamly is OK but in Disconnected Scenario, I have error
Please help !. My snipt code as following:
Request
public class ApplicationDbRepository : RepositoryBase, IReadRepository, IRepository
where T : class, IAggregateRoot
{
public ApplicationDbRepository(ApplicationDbContext dbContext)
: base(dbContext)
{
}
protected override IQueryable ApplySpecification(ISpecification<T, TResult> specification) =>
specification.Selector is not null
? base.ApplySpecification(specification)
: ApplySpecification(specification, false)
.ProjectToType();
public class ApplicationDbContext : DbContext, IApplicationDbContext { public DbSet Vendors { get; set; }
public ApplicationDbContext(DbContextOptions options)
: base(options)
{ }
public async Task SaveChanges()
{
return await base.SaveChangesAsync();
}
public class Vendor : BaseEntity, IAggregateRoot { public string Code { get; set; } public string Name { get; set; } public string? Description { get; set; } } public abstract class BaseEntity { public int Id { get; set; } }