namespace Abp.Domain.Repositories
{
//
// Сводка:
// A shortcut of Abp.Domain.Repositories.IRepository`2 for most used primary key
// type (System.Int32).
//
// Параметры типа:
// TEntity:
// Entity type
public interface IRepository<TEntity> : IRepository<TEntity, int>, IRepository, ITransientDependency where TEntity : class, IEntity<int>
{
}
}
private readonly IRepository<Child> _childRepository;
Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate);
public async Task CreateOrEdit(CreateOrEditChildDto input)
{
if (input.Id == null)
{
await Create(input);
}
else
{
await Update(input);
}
}
protected virtual async Task Update(CreateOrEditChildDto input)
{
var child = await _childRepository.FirstOrDefaultAsync(x => x.Id == (int)input.Id);
}
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
public DbSet<Category> Categories { get; set; }
public DbSet<CoverType> CoverTypes { get; set; }
public DbSet<Product> Products { get; set; }
}
public interface IUnitOfWork
{
ICategoryRepository Category { get; }
ICoverTypeRepository CoverType { get; }
IProductRepository Product { get; }
void Save();
}