1

I am executing following query. I am doing this in aspnetzero framework and doing this in UserAppService.cs file.

var rt = _dbContextProvider.GetDbContext().Users
                    .Where(e => e.Id == 11)
                    .FirstOrDefault();

But this is always returning null, in database there is record with Id = 11.

So anyone has any idea what is wrong in this.

Thanks

2
  • Chances are your application is using a connection string to a database you aren't expecting. Check the value of _dbContextProvider.GetDbContext().Database.Connection.ConnectionString to verify that it is connecting to the same database server/instance you are inspecting for records. Also check that your context hasn't added alternate tables based on the naming convention. (I.e. under default namespace or pluralized class name) Commented Dec 6, 2020 at 22:35
  • 2
    Try to add .IgnoreQueryFilters(), probably you have defined query filters. Commented Dec 6, 2020 at 23:08

1 Answer 1

1

As Svyatoslav Danyliv said in the comment, the issue is related to the query filters, try to add the .IgnoreQueryFilters() to ignore the query filters.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.