848 lines
30 KiB
C#
848 lines
30 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.EntityFrameworkCore.Query;
|
|
using xAiModels.Configurations;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xAiModels.Interfaces.Enrichers;
|
|
using xAiModels.Interfaces.Entities;
|
|
using xAiModels.Models.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using xCommons.Extensions;
|
|
using xDataService.Providers;
|
|
using xModels.Dtos;
|
|
|
|
namespace xAiModels.Providers.Dtos
|
|
{
|
|
public class XAiProjectRepositoryService : XBaseRepositoryService<XAiProject, XAiProjectDto, Guid>, IXAiProjectRepositoryService
|
|
{
|
|
private readonly IXAiProjectEnricher enricher;
|
|
|
|
public XAiProjectRepositoryService(
|
|
IXAiProjectEnricher enricher,
|
|
IXAiProjectRepository repository
|
|
) : base(
|
|
repository,
|
|
mapperProfiles:
|
|
[
|
|
new XAiModelMappersProfile()
|
|
]
|
|
)
|
|
{
|
|
this.enricher = enricher;
|
|
}
|
|
|
|
|
|
//
|
|
#region Actions Base ...
|
|
//
|
|
#region Add ...
|
|
/// <summary>
|
|
/// add a new Dto ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="saveChanges"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public override async Task<XAiProjectDto> AddAsync(
|
|
XAiProjectDto item,
|
|
bool saveChanges = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return await AddAsync(
|
|
item: item,
|
|
saveChanges: saveChanges,
|
|
fillConversations: false,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// add or update a Dto (add if not exists/update if exists) ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="saveChanges"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public override async Task<XAiProjectDto> AddOrUpdateAsync(
|
|
XAiProjectDto item,
|
|
bool saveChanges = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return await AddOrUpdateAsync(
|
|
item: item,
|
|
saveChanges: saveChanges,
|
|
fillConversations: false,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Update ...
|
|
/// <summary>
|
|
/// Update an Dto values ...
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="item"></param>
|
|
/// <param name="saveChanges"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public override async Task<XAiProjectDto> UpdateAsync(
|
|
Guid id,
|
|
XAiProjectDto item,
|
|
bool saveChanges = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return await UpdateAsync(
|
|
id: id,
|
|
item: item,
|
|
saveChanges: saveChanges,
|
|
fillConversations: false,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Remove ...
|
|
/// <summary>
|
|
/// remove an Dto by it's Id ...
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="softDelete"></param>
|
|
/// <param name="saveChanges"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public override async Task<XAiProjectDto> RemoveAsync(
|
|
Guid id,
|
|
bool softDelete = false,
|
|
bool saveChanges = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return await RemoveAsync(
|
|
id: id,
|
|
softDelete: softDelete,
|
|
saveChanges: saveChanges,
|
|
fillConversations: false,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// remove an Dto ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="softDelete"></param>
|
|
/// <param name="saveChanges"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public override async Task<XAiProjectDto> RemoveAsync(
|
|
XAiProjectDto item,
|
|
bool softDelete = false,
|
|
bool saveChanges = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return await RemoveAsync(
|
|
item: item,
|
|
softDelete: softDelete,
|
|
saveChanges: saveChanges,
|
|
fillConversations: false,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Retrieve ...
|
|
/// <summary>
|
|
/// retrieve an Dto by it's Id ...
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="ignoreSoftDeleteds"></param>
|
|
/// <param name="includeBuilder"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public override async Task<XAiProjectDto> GetAsync(
|
|
Guid id,
|
|
bool ignoreSoftDeleteds = true,
|
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return await GetAsync(
|
|
id: id,
|
|
fillConversations: false,
|
|
includeBuilder: includeBuilder,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken,
|
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// retrieve all exists Dtos ...
|
|
/// </summary>
|
|
/// <param name="ignoreSoftDeleteds"></param>
|
|
/// <param name="orderBuilder"></param>
|
|
/// <param name="includeBuilder"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public override async Task<IEnumerable<XAiProjectDto>> GetAllAsync(
|
|
bool ignoreSoftDeleteds = true,
|
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return await GetAllAsync(
|
|
fillConversations: false,
|
|
orderBuilder: orderBuilder,
|
|
includeBuilder: includeBuilder,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken,
|
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// retrieve all exists Dtos
|
|
/// as Async Enumerable ...
|
|
/// </summary>
|
|
/// <param name="ignoreSoftDeleteds"></param>
|
|
/// <param name="orderBuilder"></param>
|
|
/// <param name="includeBuilder"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public override IAsyncEnumerable<XAiProjectDto> GetAllAsAsyncEnumerable(
|
|
bool ignoreSoftDeleteds = true,
|
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return GetAllAsAsyncEnumerable(
|
|
fillConversations: false,
|
|
orderBuilder: orderBuilder,
|
|
includeBuilder: includeBuilder,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken,
|
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// find an Dto by providing a Conditional Expression ...
|
|
/// </summary>
|
|
/// <param name="predicate"></param>
|
|
/// <param name="ignoreSoftDeleteds"></param>
|
|
/// <param name="includeBuilder"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public override async Task<XAiProjectDto> FindOneAsync(
|
|
Expression<Func<XAiProject, bool>> predicate,
|
|
bool ignoreSoftDeleteds = true,
|
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return await FindOneAsync(
|
|
predicate: predicate,
|
|
fillConversations: false,
|
|
includeBuilder: includeBuilder,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken,
|
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// find a collection of Dtos by proving a Conditional Expression ...
|
|
/// </summary>
|
|
/// <param name="predicate"></param>
|
|
/// <param name="ignoreSoftDeleteds"></param>
|
|
/// <param name="orderBuilder"></param>
|
|
/// <param name="includeBuilder"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public override async Task<IEnumerable<XAiProjectDto>> FindManyAsync(
|
|
Expression<Func<XAiProject, bool>> predicate,
|
|
bool ignoreSoftDeleteds = true,
|
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return await FindManyAsync(
|
|
predicate: predicate,
|
|
fillConversations: false,
|
|
orderBuilder: orderBuilder,
|
|
includeBuilder: includeBuilder,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken,
|
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// retrieve Dtos based on XQuery Pagination structure ...
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <param name="ignoreSoftDeleteds"></param>
|
|
/// <param name="predicate"></param>
|
|
/// <param name="orderBuilder"></param>
|
|
/// <param name="includeBuilder"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public override async Task<XQueryResult<XAiProjectDto>> QueryAsync(
|
|
XQuery query,
|
|
bool ignoreSoftDeleteds = true,
|
|
Expression<Func<XAiProject, bool>> predicate = null,
|
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return await QueryAsync(
|
|
query: query,
|
|
predicate: predicate,
|
|
fillConversations: false,
|
|
orderBuilder: orderBuilder,
|
|
includeBuilder: includeBuilder,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken,
|
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
|
);
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
//
|
|
#region Actions ...
|
|
//
|
|
#region Add ...
|
|
/// <summary>
|
|
/// add a new Dto ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="saveChanges"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiProjectDto> AddAsync(
|
|
XAiProjectDto item,
|
|
bool saveChanges = true,
|
|
bool fillConversations = true,
|
|
bool fillConversationMessages = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.AddAsync(
|
|
item: item,
|
|
saveChanges: saveChanges,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Do Enrichment if result Exists ...
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
await enricher.EnrichAsync(
|
|
source: result,
|
|
destination: result,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// add or update a Dto (add if not exists/update if exists) ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="saveChanges"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiProjectDto> AddOrUpdateAsync(
|
|
XAiProjectDto item,
|
|
bool saveChanges = true,
|
|
bool fillConversations = true,
|
|
bool fillConversationMessages = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.AddAsync(
|
|
item: item,
|
|
saveChanges: saveChanges,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Do Enrichment if result Exists ...
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
await enricher.EnrichAsync(
|
|
source: result,
|
|
destination: result,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Update ...
|
|
/// <summary>
|
|
/// Update an Dto values ...
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="item"></param>
|
|
/// <param name="saveChanges"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiProjectDto> UpdateAsync(
|
|
Guid id,
|
|
XAiProjectDto item,
|
|
bool saveChanges = true,
|
|
bool fillConversations = true,
|
|
bool fillConversationMessages = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.UpdateAsync(
|
|
id: id,
|
|
item: item,
|
|
saveChanges: saveChanges,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Do Enrichment if result Exists ...
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
await enricher.EnrichAsync(
|
|
source: result,
|
|
destination: result,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Remove ...
|
|
/// <summary>
|
|
/// remove an Dto by it's Id ...
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="softDelete"></param>
|
|
/// <param name="saveChanges"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiProjectDto> RemoveAsync(
|
|
Guid id,
|
|
bool softDelete = false,
|
|
bool saveChanges = true,
|
|
bool fillConversations = true,
|
|
bool fillConversationMessages = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.RemoveAsync(
|
|
id: id,
|
|
softDelete: softDelete,
|
|
saveChanges: saveChanges,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Do Enrichment if result Exists ...
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
await enricher.EnrichAsync(
|
|
source: result,
|
|
destination: result,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// remove an Dto ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="softDelete"></param>
|
|
/// <param name="saveChanges"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiProjectDto> RemoveAsync(
|
|
XAiProjectDto item,
|
|
bool softDelete = false,
|
|
bool saveChanges = true,
|
|
bool fillConversations = true,
|
|
bool fillConversationMessages = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.RemoveAsync(
|
|
item: item,
|
|
softDelete: softDelete,
|
|
saveChanges: saveChanges,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Do Enrichment if result Exists ...
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
await enricher.EnrichAsync(
|
|
source: result,
|
|
destination: result,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Retrieve ...
|
|
/// <summary>
|
|
/// retrieve an Dto by it's Id ...
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="ignoreSoftDeleteds"></param>
|
|
/// <param name="includeBuilder"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiProjectDto> GetAsync(
|
|
Guid id,
|
|
bool ignoreSoftDeleteds = true,
|
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
|
bool fillConversations = true,
|
|
bool fillConversationMessages = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.GetAsync(
|
|
id: id,
|
|
includeBuilder: includeBuilder,
|
|
cancellationToken: cancellationToken,
|
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
|
);
|
|
|
|
//
|
|
// Do Enrichment if result Exists ...
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
await enricher.EnrichAsync(
|
|
source: result,
|
|
destination: result,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// retrieve all exists Dtos ...
|
|
/// </summary>
|
|
/// <param name="ignoreSoftDeleteds"></param>
|
|
/// <param name="orderBuilder"></param>
|
|
/// <param name="includeBuilder"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiProjectDto>> GetAllAsync(
|
|
bool ignoreSoftDeleteds = true,
|
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
|
bool fillConversations = true,
|
|
bool fillConversationMessages = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.GetAllAsync(
|
|
orderBuilder: orderBuilder,
|
|
includeBuilder: includeBuilder,
|
|
cancellationToken: cancellationToken,
|
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
|
);
|
|
|
|
//
|
|
// Do Enrichment if result Exists ...
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
await enricher.EnrichRangeAsync(
|
|
sources: result,
|
|
destinations: result,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// retrieve all exists Dtos
|
|
/// as Async Enumerable ...
|
|
/// </summary>
|
|
/// <param name="ignoreSoftDeleteds"></param>
|
|
/// <param name="orderBuilder"></param>
|
|
/// <param name="includeBuilder"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async IAsyncEnumerable<XAiProjectDto> GetAllAsAsyncEnumerable(
|
|
bool ignoreSoftDeleteds = true,
|
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
|
bool fillConversations = true,
|
|
bool fillConversationMessages = true,
|
|
[EnumeratorCancellation] CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var enumerable = base.GetAllAsAsyncEnumerable(
|
|
orderBuilder: orderBuilder,
|
|
includeBuilder: includeBuilder,
|
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
|
);
|
|
await foreach (var dto in enumerable)
|
|
{
|
|
//
|
|
if (cancellationToken.IsCancellationRequested)
|
|
{
|
|
yield break;
|
|
}
|
|
|
|
//
|
|
await enricher.EnrichAsync(
|
|
source: dto,
|
|
destination: dto,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
yield return dto;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// find an Dto by providing a Conditional Expression ...
|
|
/// </summary>
|
|
/// <param name="predicate"></param>
|
|
/// <param name="ignoreSoftDeleteds"></param>
|
|
/// <param name="includeBuilder"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiProjectDto> FindOneAsync(
|
|
Expression<Func<XAiProject, bool>> predicate,
|
|
bool ignoreSoftDeleteds = true,
|
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
|
bool fillConversations = true,
|
|
bool fillConversationMessages = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.FindOneAsync(
|
|
predicate: predicate,
|
|
includeBuilder: includeBuilder,
|
|
cancellationToken: cancellationToken,
|
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
|
);
|
|
|
|
//
|
|
// Do Enrichment if result Exists ...
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
await enricher.EnrichAsync(
|
|
source: result,
|
|
destination: result,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// find a collection of Dtos by proving a Conditional Expression ...
|
|
/// </summary>
|
|
/// <param name="predicate"></param>
|
|
/// <param name="ignoreSoftDeleteds"></param>
|
|
/// <param name="orderBuilder"></param>
|
|
/// <param name="includeBuilder"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiProjectDto>> FindManyAsync(
|
|
Expression<Func<XAiProject, bool>> predicate,
|
|
bool ignoreSoftDeleteds = true,
|
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
|
bool fillConversations = true,
|
|
bool fillConversationMessages = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.FindManyAsync(
|
|
predicate: predicate,
|
|
orderBuilder: orderBuilder,
|
|
includeBuilder: includeBuilder,
|
|
cancellationToken: cancellationToken,
|
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
|
);
|
|
|
|
//
|
|
// Do Enrichment if result Exists ...
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
await enricher.EnrichRangeAsync(
|
|
sources: result,
|
|
destinations: result,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// retrieve Dtos based on XQuery Pagination structure ...
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <param name="ignoreSoftDeleteds"></param>
|
|
/// <param name="predicate"></param>
|
|
/// <param name="orderBuilder"></param>
|
|
/// <param name="includeBuilder"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XQueryResult<XAiProjectDto>> QueryAsync(
|
|
XQuery query,
|
|
bool ignoreSoftDeleteds = true,
|
|
Expression<Func<XAiProject, bool>> predicate = null,
|
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
|
bool fillConversations = true,
|
|
bool fillConversationMessages = true,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.QueryAsync(
|
|
query: query,
|
|
predicate: predicate,
|
|
orderBuilder: orderBuilder,
|
|
includeBuilder: includeBuilder,
|
|
cancellationToken: cancellationToken,
|
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
|
);
|
|
|
|
//
|
|
// Do Enrichment if result Exists ...
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
await enricher.EnrichRangeAsync(
|
|
sources: result.Items,
|
|
destinations: result.Items,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
}
|
|
} |