Oh...
ITenantRepository tenantRepository = this.LazyServiceProvider.LazyGetRequiredService<ITenantRepository>();
tenantRepository is null
2022-11-17 11:10:23.791 +08:00 [INF] Starting: 【扫码关注】积分发放... 2022-11-17 11:10:46.619 +08:00 [ERR] Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. at Yee.Change.AdminBlazorUI.WorkItems.FansJoinedNotifierWorkItem.FansSubscribedPoint() in D:\dev\abp\change\admin-blazor-ui\src\Yee.Change.AdminBlazorUI.Application\WorkItems\FansJoinedNotifierWorkItem.cs:line 97 at Yee.Change.AdminBlazorUI.WorkItems.FansJoinedNotifierWorkItem.DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) in D:\dev\abp\change\admin-blazor-ui\src\Yee.Change.AdminBlazorUI.Application\WorkItems\FansJoinedNotifierWorkItem.cs:line 56 at Volo.Abp.BackgroundWorkers.AsyncPeriodicBackgroundWorkerBase.DoWorkAsync(CancellationToken cancellationToken) 2022-11-17 11:10:51.016 +08:00 [INF] Initialized all ABP modules.
and I try another way,
ICurrentTenant currentTenant = this.LazyServiceProvider.LazyGetRequiredService<ICurrentTenant>();
ITenantRepository tenantRepository = this.LazyServiceProvider.LazyGetRequiredService<ITenantRepository>();
if (allTenants == null)
{
using (currentTenant.Change(null))
{
allTenants = await tenantRepository.GetListAsync();
}
}
got the same error again: Object reference not set to an instance of an object.
public class FansJoinedNotifierWorkItem : AsyncPeriodicBackgroundWorkerBase
{
public FansJoinedNotifierWorkItem(AbpAsyncTimer timer, IServiceScopeFactory serviceScopeFactory) : base(timer, serviceScopeFactory)
{
this.Timer.Period = 60 * 1000;
}
protected async override Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
{
this.Timer.Period = 1440 * 60 * 1000;
扫码关注送积分 subscribPoint = new 扫码关注送积分();
subscribPoint.LazyServiceProvider = this.LazyServiceProvider;
await this.FansSubscribedPoint();
this.Timer.Period = siteOptions.Value.UserFollowNotifyIntervalMinutes * 60 * 1000;
}
static List<Tenant> allTenants;
public async Task FansSubscribedPoint()
{
Log.Information("Starting: 【扫码关注】积分发放...");
IDataFilter dataFilter = this.LazyServiceProvider.LazyGetRequiredService<IDataFilter>();
if (allTenants == null)
{
using (dataFilter.Disable<IMultiTenant>())
{
ITenantRepository tenantRepository = this.LazyServiceProvider.LazyGetRequiredService<ITenantRepository>();
allTenants = await tenantRepository.GetListAsync();
}
}
……
Log.Information("Completed: 【扫码关注】积分发放...");
}
}
Volo.Abp.Identity.Pro.Domain need standard 2.1?
So I must change all of my projects with Domain from NET Standard 2.0 to NET Standard 2.1.
/builds/change/account/src/Yee.Change.Account.Domain.Shared/Yee.Change.Account.Domain.Shared.csproj : error NU1103: Unable to find a stable package Volo.Abp.Identity.Pro.Domain.Shared with version (>= 5.3.0)
The newest stable version of above package is 5.0.2?
var query = dbContext.Where(p => p.ItemKey == input.ItemKey && p.ItemType == input.ItemType).DistinctBy(p => p.EventTypeId);
I can not change the color of the text.
[09:15:02 WRN] Unhandled exception rendering component: The LINQ expression 'DbSet<EventDesc>()
.Where(p => (Guid?)p.ItemKey == __input_ItemKey_0 && p.ItemType == __input_ItemType_1)
.DistinctBy(p => p.EventTypeId)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
System.InvalidOperationException: The LINQ expression 'DbSet<EventDesc>()
.Where(p => (Guid?)p.ItemKey == __input_ItemKey_0 && p.ItemType == __input_ItemType_1)
.DistinctBy(p => p.EventTypeId)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.Expand(Expression query)
at Microsoft.EntityFrameworkCore.Query.QueryTranslationPreprocessor.Process(Expression query)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.Count[TSource](IQueryable`1 source)
at Yee.Change.EventRecorder.EventDescs.EventDescAppMoreService.GetAllEventsListAsync(GetEventDescsInput input) in D:\abp-change\event-recorder\src\Yee.Change.EventRecorder.Application\EventDescs\EventDescAppMoreService.cs:line 38
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope)
at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Yee.Change.EventRecorder.Blazor.Shared.MyCaseWorksListView.OnInitializedAsync() in D:\abp-change\event-recorder\src\Yee.Change.EventRecorder.Blazor\Shared\MyCaseWorksListView.razor:line 28
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
[Authorize(EventRecorderPermissions.EventDescs.Default)]
public class EventDescAppMoreService : ApplicationService, IEventDescAppMoreService
{
private readonly IEventDescRepository _eventDescRepository;
private readonly EventDescManager _eventDescManager;
private readonly IRepository<ReplyRole, Guid> _replyRoleRepository;
public EventDescAppMoreService(IEventDescRepository eventDescRepository, EventDescManager eventDescManager, IRepository<ReplyRole, Guid> replyRoleRepository)
{
_eventDescRepository = eventDescRepository;
_eventDescManager = eventDescManager; _replyRoleRepository = replyRoleRepository;
}
public virtual async Task<PagedResultDto<EventDescDto>> GetAllEventsListAsync(GetEventDescsInput input)
{
var dbContext = await this._eventDescRepository.GetQueryableAsync();
var query = dbContext.Where(p => p.ItemKey == input.ItemKey && p.ItemType == input.ItemType).**DistinctBy(p => p.EventTypeId);**
int totalCount = query.Count();
return new PagedResultDto<EventDescDto>
{
TotalCount = totalCount,
Items = ObjectMapper.Map<List<EventDesc>, List<EventDescDto>>(query.Skip(input.SkipCount).Take(input.MaxResultCount).ToList())
};
}
}
tks a lot!