Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triggers Dependency injection not working #59

Open
mohammed-yehia-zkaria opened this issue Oct 1, 2020 · 5 comments
Open

Triggers Dependency injection not working #59

mohammed-yehia-zkaria opened this issue Oct 1, 2020 · 5 comments

Comments

@mohammed-yehia-zkaria
Copy link

            Triggers<ITrackable<User, int>,DDD_Context>.GlobalInserting.Add<IClaimService>(entry =>
            {
                var service = entry.Service;
                entry.Entity.CreatedAt = DateTime.Now;
                entry.Entity.UpdatedAt = DateTime.Now;
                entry.Entity.CreatedById = service.CurrentUser.Id;
                entry.Entity.UpdatedById = service.CurrentUser.Id;
            });
@mohammed-yehia-zkaria mohammed-yehia-zkaria changed the title Triggers Dependency injection not work Triggers Dependency injection not working Oct 1, 2020
@mohammed-yehia-zkaria
Copy link
Author

exception is
Value cannot be null. (Parameter 'provider')

@NickStrupat
Copy link
Owner

I'm not sure that exception is coming from this library. I just did a global search for provider and didn't get any results for a parameter named provider.

Do you have a minimal sample project showing the exception?

@mohammed-yehia-zkaria
Copy link
Author

package used NickStrupat.EntityFrameworkCore.Triggers.AspNetCore version 1.0.3

@mohammed-yehia-zkaria
Copy link
Author

stacktrace

at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)\r\n at lambda_method(Closure , IServiceProvider )\r\n at EntityFrameworkCore.Triggers.ServiceRetrieval1.GetService(IServiceProvider serviceProvider)\r\n at EntityFrameworkCore.Triggers.WrappedEntry4..ctor(TEntry entry)\r\n at EntityFrameworkCore.Triggers.WrappedBeforeEntry4..ctor(TEntry entry)\r\n at EntityFrameworkCore.Triggers.WrappedInsertingEntry3..ctor(IInsertingEntry2 entry)\r\n at EntityFrameworkCore.Triggers.InsertingTriggerEvent2.<>c__DisplayClass0_01.<Add>b__0(IInsertingEntry2 entry)\r\n at EntityFrameworkCore.Triggers.DelegateSynchronyUnion1.Invoke(T value)\r\n at EntityFrameworkCore.Triggers.TriggerEvent3.WrappedHandler.Invoke(TEntry entry)\r\n at EntityFrameworkCore.Triggers.TriggerEvent3.RaiseInternal(Object entry)\r\n at EntityFrameworkCore.Triggers.TriggerEvent.Raise(Object entry)\r\n at EntityFrameworkCore.Triggers.TriggerEventExtensions.Raise(ITriggerEvent triggersEvent, Object entry)\r\n at EntityFrameworkCore.Triggers.TriggerEntityInvoker2.<>c__DisplayClass19_11.<GetRaiseActions>g__RaiseGlobalThenInstance|3(TEntry entry, IServiceProvider sp)\r\n at EntityFrameworkCore.Triggers.TriggerEntityInvoker2.<>c__DisplayClass19_01.<GetRaiseActions>g__RaiseActions|0(TEntry entry, IServiceProvider sp)\r\n at EntityFrameworkCore.Triggers.TriggerEntityInvoker2.RaiseInserting(IServiceProvider sp, Object entity, TDbContext dbc, Boolean& cancel)\r\n at EntityFrameworkCore.Triggers.TriggerInvoker1.RaiseChangingEvent(EntityEntry entry, DbContext dbContext, IServiceProvider serviceProvider, Boolean& cancel)\r\n at EntityFrameworkCore.Triggers.TriggerInvoker1.RaiseChangingEvents(DbContext dbContext, IServiceProvider serviceProvider)\r\n at EntityFrameworkCore.Triggers.DbContextExtensions.SaveChangesWithTriggers(DbContext dbContext, Func2 baseSaveChanges, IServiceProvider serviceProvider, Boolean acceptAllChangesOnSuccess)\r\n at EntityFrameworkCore.Triggers.DbContextExtensions.SaveChangesWithTriggers(DbContext dbContext, Func2 baseSaveChanges, Boolean acceptAllChangesOnSuccess)\r\n at DDD.Data.Context.DDD_Context.SaveChanges() in D:\learning\DDD_DotNet\DDD\DDD.Data\Database\Context.cs:line 23\r\n at DDD.Data.UnitOfWork.Commit() in D:\learning\DDD_DotNet\DDD\DDD.Data\UnitOfWork.cs:line 36\r\n at DDD.Core.Services.PolicyService.AddPolicy(PolicyDto policyDto) in D:\learning\DDD_DotNet\DDD\DDD.Core\Services\PolicyService.cs:line 55\r\n at DDD.API.Controllers.WeatherForecastController.PostPolciy(PolicyDto policy) in D:\learning\DDD_DotNet\DDD\DDD.API\Controllers\WeatherForecastController.cs:line 79\r\n at lambda_method(Closure , Object , Object[] )\r\n at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)\r\n at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)\r\n at DDD.API.Middlewares.ExceptionHandlerMiddleware.Invoke(HttpContext context) in D:\learning\DDD_DotNet\DDD\DDD.API\Middlewares\ExceptionHandlerMiddleware.cs:line 30",

@NickStrupat
Copy link
Owner

I can't really help you with just a stack trace. I need to see code that recreates this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants