fix GraphQL DI Registration Using Generics ...

This commit is contained in:
2026-05-10 00:12:59 +03:30
parent 49c6872fcf
commit 07f4435f9a
6 changed files with 530 additions and 138 deletions
+45
View File
@@ -0,0 +1,45 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using xCommons.Extensions;
using xDataService.Extensions;
using xDataService.Interfaces;
using xModels.Base;
namespace xDataService.Providers
{
/// <summary>
/// Default Long Key Generator ...
/// </summary>
/// <typeparam name="TEntity"></typeparam>
public class XLongKeyGenerator<TEntity> : XKeyGenerator<TEntity, long>, IXKeyGenerator<TEntity, long>
where TEntity : XBaseEntity<long>
{
public override async Task<long> GenerateKey(
IXBaseRepository<TEntity, long> repository,
CancellationToken cancellationToken = default
)
{
//
var items = (await repository.GetAllAsync())
.OrderByDescending(nameof(XBaseEntity<long>.Id));
var last = items
.FirstOrDefault();
//
var result = last.IsNull() ? 1 : last.Id + 1;
//
return result;
}
public override bool IsEmpty(long id)
{
//
var result = id <= 0;
//
return result;
}
}
}