Because I use "Customizable Code" option so I have two files: EfCoreListOrganizationRepository.cs
public class EfCoreListOrganizationRepositoryBase : EfCoreRepository<IAdminCategoryServiceDbContext, ListOrganization, long>
{
public EfCoreListOrganizationRepositoryBase(IDbContextProvider<IAdminCategoryServiceDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public virtual async Task DeleteAllAsync(
string? filterText = null,
long? nodeIdMin = null,
long? nodeIdMax = null,
string? orgName = null,
string? orgShortcut = null,
long? orgNodeIdMin = null,
long? orgNodeIdMax = null,
int? orgOrderMin = null,
int? orgOrderMax = null,
string? orgMap = null,
string? dataOwner = null,
short? statusMin = null,
short? statusMax = null,
string? textSearch = null,
Guid? guidId = null,
string? code = null,
string? emailAddress = null,
string? phoneNumber = null,
string? address = null,
string? cityId = null,
string? districtId = null,
short? portalOrgTypeMin = null,
short? portalOrgTypeMax = null,
short? fromSourceTypeMin = null,
short? fromSourceTypeMax = null,
short? isRegisterPortalMin = null,
short? isRegisterPortalMax = null,
Guid? portalGuidId = null,
CancellationToken cancellationToken = default)
{
var query = await GetQueryableAsync();
query = ApplyFilter(query, filterText, nodeIdMin, nodeIdMax, orgName, orgShortcut, orgNodeIdMin, orgNodeIdMax, orgOrderMin, orgOrderMax, orgMap, dataOwner, statusMin, statusMax, textSearch, guidId, code, emailAddress, phoneNumber, address, cityId, districtId, portalOrgTypeMin, portalOrgTypeMax, fromSourceTypeMin, fromSourceTypeMax, isRegisterPortalMin, isRegisterPortalMax, portalGuidId);
var ids = query.Select(x => x.Id);
await DeleteManyAsync(ids, cancellationToken: GetCancellationToken(cancellationToken));
}
public virtual async Task<List<ListOrganization>> GetListAsync(
string? filterText = null,
long? nodeIdMin = null,
long? nodeIdMax = null,
string? orgName = null,
string? orgShortcut = null,
long? orgNodeIdMin = null,
long? orgNodeIdMax = null,
int? orgOrderMin = null,
int? orgOrderMax = null,
string? orgMap = null,
string? dataOwner = null,
short? statusMin = null,
short? statusMax = null,
string? textSearch = null,
Guid? guidId = null,
string? code = null,
string? emailAddress = null,
string? phoneNumber = null,
string? address = null,
string? cityId = null,
string? districtId = null,
short? portalOrgTypeMin = null,
short? portalOrgTypeMax = null,
short? fromSourceTypeMin = null,
short? fromSourceTypeMax = null,
short? isRegisterPortalMin = null,
short? isRegisterPortalMax = null,
Guid? portalGuidId = null,
string? sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
var query = ApplyFilter((await GetQueryableAsync()), filterText, nodeIdMin, nodeIdMax, orgName, orgShortcut, orgNodeIdMin, orgNodeIdMax, orgOrderMin, orgOrderMax, orgMap, dataOwner, statusMin, statusMax, textSearch, guidId, code, emailAddress, phoneNumber, address, cityId, districtId, portalOrgTypeMin, portalOrgTypeMax, fromSourceTypeMin, fromSourceTypeMax, isRegisterPortalMin, isRegisterPortalMax, portalGuidId);
query = query.OrderBy(string.IsNullOrWhiteSpace(sorting) ? ListOrganizationConsts.GetDefaultSorting(false) : sorting);
return await query.PageBy(skipCount, maxResultCount).ToListAsync(cancellationToken);
}
public virtual async Task<long> GetCountAsync(
string? filterText = null,
long? nodeIdMin = null,
long? nodeIdMax = null,
string? orgName = null,
string? orgShortcut = null,
long? orgNodeIdMin = null,
long? orgNodeIdMax = null,
int? orgOrderMin = null,
int? orgOrderMax = null,
string? orgMap = null,
string? dataOwner = null,
short? statusMin = null,
short? statusMax = null,
string? textSearch = null,
Guid? guidId = null,
string? code = null,
string? emailAddress = null,
string? phoneNumber = null,
string? address = null,
string? cityId = null,
string? districtId = null,
short? portalOrgTypeMin = null,
short? portalOrgTypeMax = null,
short? fromSourceTypeMin = null,
short? fromSourceTypeMax = null,
short? isRegisterPortalMin = null,
short? isRegisterPortalMax = null,
Guid? portalGuidId = null,
CancellationToken cancellationToken = default)
{
var query = ApplyFilter((await GetDbSetAsync()), filterText, nodeIdMin, nodeIdMax, orgName, orgShortcut, orgNodeIdMin, orgNodeIdMax, orgOrderMin, orgOrderMax, orgMap, dataOwner, statusMin, statusMax, textSearch, guidId, code, emailAddress, phoneNumber, address, cityId, districtId, portalOrgTypeMin, portalOrgTypeMax, fromSourceTypeMin, fromSourceTypeMax, isRegisterPortalMin, isRegisterPortalMax, portalGuidId);
return await query.LongCountAsync(GetCancellationToken(cancellationToken));
}
protected virtual IQueryable<ListOrganization> ApplyFilter(
IQueryable<ListOrganization> query,
string? filterText = null,
long? nodeIdMin = null,
long? nodeIdMax = null,
string? orgName = null,
string? orgShortcut = null,
long? orgNodeIdMin = null,
long? orgNodeIdMax = null,
int? orgOrderMin = null,
int? orgOrderMax = null,
string? orgMap = null,
string? dataOwner = null,
short? statusMin = null,
short? statusMax = null,
string? textSearch = null,
Guid? guidId = null,
string? code = null,
string? emailAddress = null,
string? phoneNumber = null,
string? address = null,
string? cityId = null,
string? districtId = null,
short? portalOrgTypeMin = null,
short? portalOrgTypeMax = null,
short? fromSourceTypeMin = null,
short? fromSourceTypeMax = null,
short? isRegisterPortalMin = null,
short? isRegisterPortalMax = null,
Guid? portalGuidId = null)
{
return query
.WhereIf(!string.IsNullOrWhiteSpace(filterText), e => e.OrgName!.Contains(filterText!) || e.OrgShortcut!.Contains(filterText!) || e.OrgMap!.Contains(filterText!) || e.DataOwner!.Contains(filterText!) || e.TextSearch!.Contains(filterText!) || e.Code!.Contains(filterText!) || e.EmailAddress!.Contains(filterText!) || e.PhoneNumber!.Contains(filterText!) || e.Address!.Contains(filterText!) || e.CityId!.Contains(filterText!) || e.DistrictId!.Contains(filterText!))
.WhereIf(nodeIdMin.HasValue, e => e.NodeId >= nodeIdMin!.Value)
.WhereIf(nodeIdMax.HasValue, e => e.NodeId <= nodeIdMax!.Value)
.WhereIf(!string.IsNullOrWhiteSpace(orgName), e => e.OrgName.Contains(orgName))
.WhereIf(!string.IsNullOrWhiteSpace(orgShortcut), e => e.OrgShortcut.Contains(orgShortcut))
.WhereIf(orgNodeIdMin.HasValue, e => e.OrgNodeId >= orgNodeIdMin!.Value)
.WhereIf(orgNodeIdMax.HasValue, e => e.OrgNodeId <= orgNodeIdMax!.Value)
.WhereIf(orgOrderMin.HasValue, e => e.OrgOrder >= orgOrderMin!.Value)
.WhereIf(orgOrderMax.HasValue, e => e.OrgOrder <= orgOrderMax!.Value)
.WhereIf(!string.IsNullOrWhiteSpace(orgMap), e => e.OrgMap.Contains(orgMap))
.WhereIf(!string.IsNullOrWhiteSpace(dataOwner), e => e.DataOwner.Contains(dataOwner))
.WhereIf(statusMin.HasValue, e => e.Status >= statusMin!.Value)
.WhereIf(statusMax.HasValue, e => e.Status <= statusMax!.Value)
.WhereIf(!string.IsNullOrWhiteSpace(textSearch), e => e.TextSearch.Contains(textSearch))
.WhereIf(guidId.HasValue, e => e.GuidId == guidId)
.WhereIf(!string.IsNullOrWhiteSpace(code), e => e.Code.Contains(code))
.WhereIf(!string.IsNullOrWhiteSpace(emailAddress), e => e.EmailAddress.Contains(emailAddress))
.WhereIf(!string.IsNullOrWhiteSpace(phoneNumber), e => e.PhoneNumber.Contains(phoneNumber))
.WhereIf(!string.IsNullOrWhiteSpace(address), e => e.Address.Contains(address))
.WhereIf(!string.IsNullOrWhiteSpace(cityId), e => e.CityId.Contains(cityId))
.WhereIf(!string.IsNullOrWhiteSpace(districtId), e => e.DistrictId.Contains(districtId))
.WhereIf(portalOrgTypeMin.HasValue, e => e.PortalOrgType >= portalOrgTypeMin!.Value)
.WhereIf(portalOrgTypeMax.HasValue, e => e.PortalOrgType <= portalOrgTypeMax!.Value)
.WhereIf(fromSourceTypeMin.HasValue, e => e.FromSourceType >= fromSourceTypeMin!.Value)
.WhereIf(fromSourceTypeMax.HasValue, e => e.FromSourceType <= fromSourceTypeMax!.Value)
.WhereIf(isRegisterPortalMin.HasValue, e => e.IsRegisterPortal >= isRegisterPortalMin!.Value)
.WhereIf(isRegisterPortalMax.HasValue, e => e.IsRegisterPortal <= isRegisterPortalMax!.Value)
.WhereIf(portalGuidId.HasValue, e => e.PortalGuidId == portalGuidId);
}
}
EfCoreListOrganizationRepository.Extended.cs
public class EfCoreListOrganizationRepository : EfCoreListOrganizationRepositoryBase, IListOrganizationRepository
{
public EfCoreListOrganizationRepository(IDbContextProvider<IAdminCategoryServiceDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
}
See https://autofac.rtfd.io/help/no-constructors-bindable for more info.
at Autofac.Core.Activators.Reflection.ReflectionActivator.<>c__DisplayClass14_0.<UseSingleConstructorActivation>b__0(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action
1 next)
at Autofac.Builder.RegistrationBuilder3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext context, Action
1 next)
at Autofac.Extras.DynamicProxy.RegistrationExtensions.<>c__DisplayClass8_03.<EnableInterfaceInterceptors>b__1(ResolveRequestContext ctx, Action
1 next)
at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) --- End of inner exception stack trace --- at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action
1 next)
at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action
1 next)
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest& request)
at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest& request)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable
1 parameters)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass6_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2024-10-28 10:41:19.323 +07:00 [ERR] ---------- Exception Data ----------
ActivatorChain = TSD.DOCS.AdminCategoryService.ListOrganizations.ListOrganizationController -> TSD.DOCS.AdminCategoryService.ListOrganizations.ListOrganizationsAppService