Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit b9845a0

Browse files
committed
WIP implementazioni EFCore
1 parent dda9e1e commit b9845a0

File tree

3 files changed

+60
-41
lines changed

3 files changed

+60
-41
lines changed

src/CustomLibrary.EFCore/EFCore/Infrastructure/Interfaces/ICoreDatabase.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,21 @@
22

33
public interface ICoreDatabase<TEntity, TKey> : IDatabase<TEntity, TKey> where TEntity : class, IEntity<TKey>, new()
44
{
5-
Task<ListViewModel<TEntity>> GetListPaginationAsync(int pageIndex, int pageSize);
6-
Task<List<TEntity>> GetOrderByIdAscendingAsync();
7-
Task<List<TEntity>> GetOrderByIdDescendingAsync();
8-
Task<int> GetCountAsync();
5+
//Task<ListViewModel<TEntity>> GetListPaginationAsync(int pageIndex, int pageSize);
6+
//Task<List<TEntity>> GetOrderByIdAscendingAsync();
7+
//Task<List<TEntity>> GetOrderByIdDescendingAsync();
8+
//Task<int> GetCountAsync();
9+
10+
Task<List<TEntity>> GetItemsAsync(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includes,
11+
Expression<Func<TEntity, bool>> condition, CancellationToken cancellationToken = default);
12+
13+
Task<TEntity> GetItemByIdAsync(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includes,
14+
Expression<Func<TEntity, bool>> condition, CancellationToken cancellationToken = default);
15+
16+
Task<List<TEntity>> GetOrderedItemsAsync(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includes,
17+
Expression<Func<TEntity, bool>> conditionWhere, Expression<Func<TEntity, dynamic>> orderBy,
18+
OrderType orderType = OrderType.Ascending, CancellationToken cancellationToken = default);
19+
20+
Task<int> GetItemsCountAsync(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includes,
21+
Expression<Func<TEntity, bool>> condition, CancellationToken cancellationToken = default);
922
}

src/CustomLibrary.EFCore/EFCore/Infrastructure/Repository/CoreDatabase.cs

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,52 @@ public CoreDatabase(DbContext dbContext) : base(dbContext)
66
{
77
}
88

9-
public async Task<int> GetCountAsync()
10-
{
11-
var result = await DbContext.Set<TEntity>()
12-
.AsNoTracking()
13-
.ToListAsync();
9+
//public async Task<int> GetCountAsync()
10+
//{
11+
// var result = await DbContext.Set<TEntity>()
12+
// .AsNoTracking()
13+
// .ToListAsync();
1414

15-
return result.Count;
16-
}
15+
// return result.Count;
16+
//}
1717

18-
public async Task<List<TEntity>> GetOrderByIdAscendingAsync()
19-
{
20-
return await DbContext.Set<TEntity>()
21-
.OrderBy(x => x.Id)
22-
.AsNoTracking()
23-
.ToListAsync();
24-
}
18+
//public async Task<List<TEntity>> GetOrderByIdAscendingAsync()
19+
//{
20+
// return await DbContext.Set<TEntity>()
21+
// .OrderBy(x => x.Id)
22+
// .AsNoTracking()
23+
// .ToListAsync();
24+
//}
2525

26-
public async Task<List<TEntity>> GetOrderByIdDescendingAsync()
27-
{
28-
return await DbContext.Set<TEntity>()
29-
.OrderByDescending(x => x.Id)
30-
.AsNoTracking()
31-
.ToListAsync();
32-
}
26+
//public async Task<List<TEntity>> GetOrderByIdDescendingAsync()
27+
//{
28+
// return await DbContext.Set<TEntity>()
29+
// .OrderByDescending(x => x.Id)
30+
// .AsNoTracking()
31+
// .ToListAsync();
32+
//}
3333

34-
public async Task<ListViewModel<TEntity>> GetListPaginationAsync(int pageIndex, int pageSize)
35-
{
36-
var result = await DbContext.Set<TEntity>()
37-
.Skip((pageIndex - 1) * pageSize)
38-
.Take(pageSize)
39-
.AsNoTracking()
40-
.ToListAsync();
34+
//public async Task<ListViewModel<TEntity>> GetListPaginationAsync(int pageIndex, int pageSize)
35+
//{
36+
// var result = await DbContext.Set<TEntity>()
37+
// .Skip((pageIndex - 1) * pageSize)
38+
// .Take(pageSize)
39+
// .AsNoTracking()
40+
// .ToListAsync();
4141

42-
return new ListViewModel<TEntity> { Results = result, TotalCount = result.Count };
43-
}
42+
// return new ListViewModel<TEntity> { Results = result, TotalCount = result.Count };
43+
//}
44+
45+
public Task<List<TEntity>> GetItemsAsync(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includes,
46+
Expression<Func<TEntity, bool>> condition, CancellationToken cancellationToken = default) => throw new NotImplementedException();
47+
48+
public Task<TEntity> GetItemByIdAsync(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includes,
49+
Expression<Func<TEntity, bool>> condition, CancellationToken cancellationToken = default) => throw new NotImplementedException();
50+
51+
public Task<List<TEntity>> GetOrderedItemsAsync(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includes,
52+
Expression<Func<TEntity, bool>> conditionWhere, Expression<Func<TEntity, dynamic>> orderBy,
53+
OrderType orderType = OrderType.Ascending, CancellationToken cancellationToken = default) => throw new NotImplementedException();
54+
55+
public Task<int> GetItemsCountAsync(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includes,
56+
Expression<Func<TEntity, bool>> condition, CancellationToken cancellationToken = default) => throw new NotImplementedException();
4457
}

src/CustomLibrary.EFCore/EFCore/ListViewModel.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)