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

Object reference not set to an instance of an object error. #405

Open
commodus opened this issue Sep 14, 2024 · 0 comments
Open

Object reference not set to an instance of an object error. #405

commodus opened this issue Sep 14, 2024 · 0 comments

Comments

@commodus
Copy link

Hello,

I’m using version 8.0.0 of the Ardalis.Specification library. When the CreateBrandRequest event is triggered as shown in the screenshot, the FluentValidation implemented CreateBrandRequestValidator method runs. The IReadRepository _repository is injected and is not null, and the name parameter is not null, but when I call the repository method with the BrandByNameSpec parameter on line 27, I get a System.NullReferenceException: 'Object reference not set to an instance of an object.' error on this line. I would appreciate your help. Thank you.

image

Stack Trace :
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo operatorMethodInfo, IQueryable1 source, Expression expression, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo operatorMethodInfo, IQueryable1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.FirstOrDefaultAsync[TSource](IQueryable1 source, CancellationToken cancellationToken) at Ardalis.Specification.EntityFrameworkCore.RepositoryBase1.d__15.MoveNext()
at JTR.WebApi.Application.Catalog.Brands.CreateBrandRequestValidator.<>c__DisplayClass1_0.<<-ctor>b__1>d.MoveNext()

image

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

1 participant