Я пытаюсь использовать поддержку row_number для ядра фреймворка сущностей
https://www.thinktecture.com/en/entity-framework-core/row_number-support-in-2-1/
Я установил пакет Thinktecture.EntityFrameworkCore.SqlServer
, а затем добавил его в опцию обслуживания.
services
.AddDbContext<DemoDbContext>(builder => builder
.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), sqlOptions =>
{
sqlOptions.AddRowNumberSupport();
});
пытаюсь получить номер строки:
var query = _context.ChatMessages
.Where(o => o.SenderID.Equals("a90566ab-eef7-4f57-8e96-a3b7cc8ce786"))
.Select(i => new
{
i.message,
i.ReciverID,
RowNumber = EF.Functions.RowNumber(i.ReciverID)
}).ToList()
, но я получил ошибку:
Could not load type 'Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.IExpressionFragmentTranslator'
from assembly 'Microsoft.EntityFrameworkCore.Relational, Version=3.1.3.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60'.
след:
at Thinktecture.SqlServerDbContextOptionsBuilderExtensions.AddRowNumberSupport(SqlServerDbContextOptionsBuilder sqlServerOptionsBuilder, Boolean addRowNumberSupport)
at Signalr_video_database.Startup.<>c.<ConfigureServices>b__5_7(SqlServerDbContextOptionsBuilder sqlOptions) in C:\DriveD\test\cSharp\signalr db inmemory angular\backend\Signalr_video_database\Signalr_video_database\Startup.cs:line 52
at Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 sqlServerOptionsAction)
at Signalr_video_database.Startup.<ConfigureServices>b__5_0(DbContextOptionsBuilder options) in C:\DriveD\test\cSharp\signalr db inmemory angular\backend\Signalr_video_database\Signalr_video_database\Startup.cs:line 49
at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass1_0`2.<AddDbContext>b__0(IServiceProvider p, DbContextOptionsBuilder b)
at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.CreateDbContextOptions[TContext](IServiceProvider applicationServiceProvider, Action`2 optionsAction)
at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass10_0`1.<AddCoreServices>b__0(IServiceProvider p)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
at Microsoft.AspNetCore.SignalR.Internal.DefaultHubActivator`1.Create()
at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher`1.<OnConnectedAsync>d__6.MoveNext()