This commit is contained in:
2026-05-15 02:51:02 +03:30
parent 2a88195d15
commit d47f57a620
17 changed files with 1268 additions and 64 deletions
@@ -4,7 +4,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using xCommons.Configurations; using xCommons.Configurations;
using xCommons.Controllers;
using xCommons.Extensions; using xCommons.Extensions;
using xCommons.Providers; using xCommons.Providers;
using xExceptions.Constants; using xExceptions.Constants;
@@ -14,7 +13,8 @@ using xDataService.Interfaces;
using System.Linq; using System.Linq;
using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query;
using System.Threading; using System.Threading;
using SQLitePCL; using xCommons.Controllers;
using Microsoft.AspNetCore.Authorization;
namespace xDataService.Controllers namespace xDataService.Controllers
{ {
@@ -23,7 +23,8 @@ namespace xDataService.Controllers
/// </summary> /// </summary>
/// <typeparam name="TEntity"></typeparam> /// <typeparam name="TEntity"></typeparam>
/// <typeparam name="TKey"></typeparam> /// <typeparam name="TKey"></typeparam>
public abstract class XBaseEntityController<TEntity, TKey> : XBaseController, IXEntityControllerActions<TEntity, TKey> [AllowAnonymous]
public abstract class XBaseRepositoryController<TEntity, TKey> : XBaseApiV1Controller, IXBaseRepositoryController<TEntity, TKey>
where TEntity : XBaseEntity<TKey> where TEntity : XBaseEntity<TKey>
{ {
// //
@@ -37,8 +38,8 @@ namespace xDataService.Controllers
// //
#region Constructor ... #region Constructor ...
protected XBaseEntityController( protected XBaseRepositoryController(
ILogger<XBaseEntityController<TEntity, TKey>> logger, ILogger<XBaseRepositoryController<TEntity, TKey>> logger,
XAppConfiguration appConfiguration, XAppConfiguration appConfiguration,
XValidationProvider validationProvider, XValidationProvider validationProvider,
IXBaseRepository<TEntity, TKey> repository, IXBaseRepository<TEntity, TKey> repository,
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@@ -23,7 +24,8 @@ namespace xDataService.Controllers
/// <typeparam name="TEntity"></typeparam> /// <typeparam name="TEntity"></typeparam>
/// <typeparam name="TDto"></typeparam> /// <typeparam name="TDto"></typeparam>
/// <typeparam name="TKey"></typeparam> /// <typeparam name="TKey"></typeparam>
public abstract class XBaseEntityDtoController<TEntity, TDto, TKey> : XBaseController, IXDomainControllerActions<TEntity, TDto, TKey> [AllowAnonymous]
public abstract class XBaseServiceController<TEntity, TDto, TKey> : XBaseApiV1Controller, IXBaseServiceController<TEntity, TDto, TKey>
where TEntity : XBaseEntity<TKey> where TEntity : XBaseEntity<TKey>
where TDto : XBaseEntityDto<TKey> where TDto : XBaseEntityDto<TKey>
{ {
@@ -36,8 +38,8 @@ namespace xDataService.Controllers
// //
#region Constructor ... #region Constructor ...
protected XBaseEntityDtoController( protected XBaseServiceController(
ILogger<XBaseEntityDtoController<TEntity, TDto, TKey>> logger, ILogger<XBaseServiceController<TEntity, TDto, TKey>> logger,
XAppConfiguration appConfiguration, XAppConfiguration appConfiguration,
XValidationProvider validationProvider, XValidationProvider validationProvider,
IXBaseRepositoryService<TEntity, TDto, TKey> repositoryService, IXBaseRepositoryService<TEntity, TDto, TKey> repositoryService,
+4 -5
View File
@@ -353,9 +353,8 @@ namespace xDataService.DI
if (isValid) if (isValid)
{ {
// //
string graphPath = $"{helper.GetGraphQLPath()}"; var graphPath = $"{helper.GetGraphQLPath()}";
// string graphPath = $"{dataServiceConfiguration.GraphQLBasePath}{helper.GetGraphQLPath()}"; var graphBasePath = $"{dataServiceConfiguration.GraphQLBasePath}";
graphPath = $"{helper.GetGraphQLPath()}";
typeof(XDataServiceHelper).InvokeGenericMethod( typeof(XDataServiceHelper).InvokeGenericMethod(
methodName: "UseXGraphQL", methodName: "UseXGraphQL",
runtimeTypes: [ runtimeTypes: [
@@ -370,9 +369,9 @@ namespace xDataService.DI
], ],
args: [ args: [
source, source,
graphBasePath,
graphPath, graphPath,
withPlayground, withPlayground
null
] ]
); );
@@ -1,11 +1,7 @@
using xCommons.Extensions; using xCommons.Extensions;
using xDataService.Db; using xDataService.Db;
using xDataService.EFRepositories;
using xDataService.Events;
using xDataService.InMemRepositories;
using xDataService.Interfaces; using xDataService.Interfaces;
using xDataService.Models; using xDataService.Models;
using xDataService.MongoRepositories;
using xDataService.Providers; using xDataService.Providers;
using xModels.Base; using xModels.Base;
+3 -3
View File
@@ -7,11 +7,11 @@ namespace xDataService.GraphQL
/// Base Entity GraphType Object ... /// Base Entity GraphType Object ...
/// </summary> /// </summary>
/// <typeparam name="TKey"></typeparam> /// <typeparam name="TKey"></typeparam>
public abstract class XBaseGraphObjectType<T, TKey> : ObjectGraphType<T> public abstract class XBaseGraphObjectType<TEntity, TKey> : ObjectGraphType<TEntity>
where T : XBaseEntity<TKey> { where TEntity : XBaseEntity<TKey> {
public XBaseGraphObjectType () { public XBaseGraphObjectType () {
// //
Name = $"{typeof(T).Name}GraphType"; Name = $"{typeof(TEntity).Name}GraphType";
// //
Field (x => x.Id); Field (x => x.Id);
+1 -1
View File
@@ -2,7 +2,7 @@ using System.Collections.Generic;
using GraphQL.Resolvers; using GraphQL.Resolvers;
using GraphQL.Types; using GraphQL.Types;
using xCommons.Extensions; using xCommons.Extensions;
using xDataService.Events; using xDataService.Providers;
using xDataService.Interfaces; using xDataService.Interfaces;
using xDataService.Models; using xDataService.Models;
using xModels.Base; using xModels.Base;
+13 -12
View File
@@ -2,6 +2,7 @@ using System;
using GraphQL; using GraphQL;
using GraphQL.Server; using GraphQL.Server;
using GraphQL.Server.Ui.Playground; using GraphQL.Server.Ui.Playground;
using GraphQL.Server.Ui.Voyager;
using GraphQL.Types; using GraphQL.Types;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@@ -12,14 +13,10 @@ using MySql.EntityFrameworkCore.Extensions;
using xCommons.Extensions; using xCommons.Extensions;
using xDataService.Constants; using xDataService.Constants;
using xDataService.Db; using xDataService.Db;
using xDataService.EFRepositories;
using xDataService.Events;
using xDataService.Extensions; using xDataService.Extensions;
using xDataService.GraphQL; using xDataService.GraphQL;
using xDataService.InMemRepositories;
using xDataService.Interfaces; using xDataService.Interfaces;
using xDataService.Models; using xDataService.Models;
using xDataService.MongoRepositories;
using xDataService.Providers; using xDataService.Providers;
using xExceptions.Constants; using xExceptions.Constants;
using xModels.Base; using xModels.Base;
@@ -1197,6 +1194,7 @@ namespace xDataService.Helpers
/// <typeparam name="TGraphTypeHelperImplementation"></typeparam> /// <typeparam name="TGraphTypeHelperImplementation"></typeparam>
/// <typeparam name="TGraphSchema"></typeparam> /// <typeparam name="TGraphSchema"></typeparam>
/// <param name="source"></param> /// <param name="source"></param>
/// <param name="graphBasePath"></param>
/// <param name="graphPath"></param> /// <param name="graphPath"></param>
/// <param name="withPlayGround"></param> /// <param name="withPlayGround"></param>
/// <param name="options"></param> /// <param name="options"></param>
@@ -1211,9 +1209,9 @@ namespace xDataService.Helpers
TGraphSchema TGraphSchema
>( >(
IApplicationBuilder source, IApplicationBuilder source,
string graphBasePath,
string graphPath, string graphPath,
bool withPlayGround = false, bool withPlayGround = false
GraphQLPlaygroundOptions options = null
) )
where TGraphSchema : Schema where TGraphSchema : Schema
where TGraphKey : IGraphType where TGraphKey : IGraphType
@@ -1231,15 +1229,18 @@ namespace xDataService.Helpers
if (withPlayGround) if (withPlayGround)
{ {
// //
if (options.IsNull()) source.UseGraphQLPlayground(new GraphQLPlaygroundOptions
{ {
options = new GraphQLPlaygroundOptions(); Path = "/ui/playground",
} GraphQLEndPoint = graphBasePath
options.Path = "/ui/playground"; });
options.GraphQLEndPoint = graphPath;
// //
source.UseGraphQLPlayground(options); source.UseGraphQLVoyager(new GraphQLVoyagerOptions
{
Path = "/ui/voyager",
GraphQLEndPoint = graphBasePath
});
} }
} }
#endregion #endregion
@@ -16,7 +16,7 @@ namespace xDataService.Interfaces
/// <typeparam name="TEntity"></typeparam> /// <typeparam name="TEntity"></typeparam>
/// <typeparam name="TDto"></typeparam> /// <typeparam name="TDto"></typeparam>
/// <typeparam name="TKey"></typeparam> /// <typeparam name="TKey"></typeparam>
public interface IXEntityControllerActions<TEntity, TKey> public interface IXBaseRepositoryController<TEntity, TKey>
where TEntity : XBaseEntity<TKey> where TEntity : XBaseEntity<TKey>
{ {
// //
@@ -16,7 +16,7 @@ namespace xDataService.Interfaces
/// <typeparam name="TEntity"></typeparam> /// <typeparam name="TEntity"></typeparam>
/// <typeparam name="TDto"></typeparam> /// <typeparam name="TDto"></typeparam>
/// <typeparam name="TKey"></typeparam> /// <typeparam name="TKey"></typeparam>
public interface IXDomainControllerActions<TEntity, TDto, TKey> public interface IXBaseServiceController<TEntity, TDto, TKey>
where TEntity : XBaseEntity<TKey> where TEntity : XBaseEntity<TKey>
where TDto : XBaseEntityDto<TKey> where TDto : XBaseEntityDto<TKey>
{ {
+1 -6
View File
@@ -4,17 +4,12 @@ using xModels.Base;
namespace xDataService.Interfaces namespace xDataService.Interfaces
{ {
/// <summary>
/// Non Generic Key Generator Interface ...
/// </summary>
public interface IXKeyGenerator { }
/// <summary> /// <summary>
/// Typed Base Key Generator ... /// Typed Base Key Generator ...
/// </summary> /// </summary>
/// <typeparam name="TEntity"></typeparam> /// <typeparam name="TEntity"></typeparam>
/// <typeparam name="TKey"></typeparam> /// <typeparam name="TKey"></typeparam>
public interface IXKeyGenerator<TEntity, TKey> : IXKeyGenerator public interface IXKeyGenerator<TEntity, TKey>
where TEntity : XBaseEntity<TKey> where TEntity : XBaseEntity<TKey>
{ {
bool IsEmpty(TKey id); bool IsEmpty(TKey id);
-4
View File
@@ -1,12 +1,8 @@
using System; using System;
using GraphQL.Types; using GraphQL.Types;
using xDataService.Db; using xDataService.Db;
using xDataService.EFRepositories;
using xDataService.Events;
using xDataService.GraphQL; using xDataService.GraphQL;
using xDataService.InMemRepositories;
using xDataService.Interfaces; using xDataService.Interfaces;
using xDataService.MongoRepositories;
using xDataService.Providers; using xDataService.Providers;
using xModels.Base; using xModels.Base;
@@ -16,7 +16,7 @@ using xDataService.Models;
using xModels.Base; using xModels.Base;
using xModels.Dtos; using xModels.Dtos;
namespace xDataService.EFRepositories namespace xDataService.Providers
{ {
/// <summary> /// <summary>
/// a Base Repository Pattern Implementation Specially for EF DBs using /// a Base Repository Pattern Implementation Specially for EF DBs using
@@ -629,14 +629,14 @@ namespace xDataService.EFRepositories
{ {
predicator = x => !x.Deleted; predicator = x => !x.Deleted;
} }
var result = await AsQueryable( var result = (await AsQueryable(
asNoTracking: true, asNoTracking: true,
orderBuilder: null, orderBuilder: null,
predicate: predicator, predicate: predicator,
includeBuilder: includeBuilder includeBuilder: includeBuilder
) )
.Where(x => GetKey(x).ToString() == id.ToString()) .ToListAsync(cancellationToken))
.FirstOrDefaultAsync(cancellationToken); .FirstOrDefault(x => GetKey(x).ToString() == id.ToString());
// //
return result; return result;
@@ -732,14 +732,14 @@ namespace xDataService.EFRepositories
{ {
predicator = x => !x.Deleted; predicator = x => !x.Deleted;
} }
var result = await AsQueryable( var result = (await AsQueryable(
asNoTracking: true, asNoTracking: true,
orderBuilder: null, orderBuilder: null,
predicate: predicator, predicate: predicator,
includeBuilder: includeBuilder includeBuilder: includeBuilder
) )
.Where(predicate) .ToListAsync(cancellationToken))
.FirstOrDefaultAsync(cancellationToken); .FirstOrDefault(predicate.Compile());
// //
return result; return result;
@@ -769,14 +769,14 @@ namespace xDataService.EFRepositories
{ {
predicator = x => !x.Deleted; predicator = x => !x.Deleted;
} }
var result = await AsQueryable( var result = (await AsQueryable(
asNoTracking: true, asNoTracking: true,
predicate: predicator, predicate: predicator,
orderBuilder: orderBuilder, orderBuilder: orderBuilder,
includeBuilder: includeBuilder includeBuilder: includeBuilder
) )
.Where(predicate) .ToListAsync(cancellationToken))
.ToListAsync(cancellationToken); .Where(predicate.Compile());
// //
return result; return result;
@@ -888,15 +888,14 @@ namespace xDataService.EFRepositories
{ {
predicator = x => !x.Deleted; predicator = x => !x.Deleted;
} }
var result = await AsQueryable( var result = (await AsQueryable(
asNoTracking: true, asNoTracking: true,
orderBuilder: null, orderBuilder: null,
includeBuilder: null, includeBuilder: null,
predicate: predicator predicate: predicator
) )
.AnyAsync( .ToListAsync(cancellationToken))
cancellationToken: cancellationToken, .Any(predicate: x => GetKey(x).ToString() == id.ToString());
predicate: x => GetKey(x).ToString() == id.ToString());
// //
return result; return result;
+17
View File
@@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using xModels.Base;
namespace xDataService.Providers
{
/// <summary>
/// Configure an Entity Specifications ...
/// </summary>
/// <typeparam name="TEntity"></typeparam>
/// <typeparam name="TKey"></typeparam>
public abstract class XBaseEntityTypeConfiguration<TEntity, TKey> : IEntityTypeConfiguration<TEntity>
where TEntity : XBaseEntity<TKey>
{
public abstract void Configure(EntityTypeBuilder<TEntity> builder);
}
}
@@ -15,7 +15,7 @@ using xDataService.Models;
using xModels.Base; using xModels.Base;
using xModels.Dtos; using xModels.Dtos;
namespace xDataService.InMemRepositories namespace xDataService.Providers
{ {
/// <summary> /// <summary>
/// a Base Repository Pattern Implementation Specially for InMemory Stores using /// a Base Repository Pattern Implementation Specially for InMemory Stores using
@@ -16,7 +16,7 @@ using xDataService.Models;
using xModels.Base; using xModels.Base;
using xModels.Dtos; using xModels.Dtos;
namespace xDataService.MongoRepositories namespace xDataService.Providers
{ {
/// <summary> /// <summary>
/// a Base Repository Pattern Implementation Specially for Mongo DBs using /// a Base Repository Pattern Implementation Specially for Mongo DBs using
@@ -5,7 +5,7 @@ using System.Reactive.Subjects;
using xDataService.Interfaces; using xDataService.Interfaces;
using xDataService.Models; using xDataService.Models;
namespace xDataService.Events { namespace xDataService.Providers {
/// <summary> /// <summary>
/// Some Events can be Raised on Some Actions Happens on Repositories ... /// Some Events can be Raised on Some Actions Happens on Repositories ...
/// this is the Base Events Class ... /// this is the Base Events Class ...
+1200 -2
View File
File diff suppressed because it is too large Load Diff