Skip to content

Commit

Permalink
refactor(genericRepository) : add T constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikoo-Asadnejad committed Mar 20, 2024
1 parent 6a37b43 commit 6e5e47f
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Product.Domain.Shared.GenericRepository.GenericRepository.Command;

public partial interface IRepository<T> where T : BaseEntity
public partial interface IRepository<T> where T : IAggregateRoot
{

Task AddAsync(T model);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Product.Domain.Shared.Base;

namespace Product.Domain.Shared.GenericRepository.GenericRepository.Command;

public partial interface IRepository<T>
public partial interface IRepository<T> where T : IAggregateRoot
{
void RollbackTransaction();
void CommitTransaction();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.Linq.Expressions;
using Product.Domain.Shared.Base;
using Product.Domain.Shared.GenericRepository.Enums;

namespace Product.Domain.Shared.GenericRepository.GenericRepository.Query;

public partial interface IQueryGenericRepository<T>
public partial interface IQueryGenericRepository<T> where T : BaseEntity
{
Task<T> FindAsync(long id);
Task<IQueryable<T>> GetQueryableAsync();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.Linq.Expressions;
using Product.Domain.Shared.Base;
using Product.Domain.Shared.GenericRepository.Enums;

namespace Product.Domain.Shared.GenericRepository.GenericRepository.Query;

public partial interface IQueryGenericRepository<T>
public partial interface IQueryGenericRepository<T> where T : BaseEntity
{
IQueryable<T> GetQueryable();
T Find(long id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Product.Infrastructure.Data.Repository.GenericRepository.Command;

public sealed partial class Repository<T> : IRepository<T> where T : BaseEntity
public sealed partial class Repository<T> : IRepository<T> where T : BaseEntity , IAggregateRoot
{

private readonly CommandContext _context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Product.Infrastructure.Data.Repository.GenericRepository.Command;

public sealed partial class Repository<T> where T : BaseEntity
public sealed partial class Repository<T> where T : BaseEntity , IAggregateRoot
{
public IDbContextTransaction BeginTransaction()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
using Product.Domain.Shared.Base;
using Product.Domain.Shared.GenericRepository.Enums;
using Product.Domain.Shared.GenericRepository.GenericRepository.Query;
using Product.Infrastructure.Data.Context;

namespace Product.Infrastructure.Data.Repository.GenericRepository.Query;

public sealed partial class QueryGenericRepository<T> : IQueryGenericRepository<T>
public sealed partial class QueryGenericRepository<T> : IQueryGenericRepository<T> where T : BaseEntity
{
private readonly QueryContext _context;
private readonly DbSet<T> _model;
Expand Down

0 comments on commit 6e5e47f

Please sign in to comment.