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