have a class based of identity user. however when I try to find a user it returns null
Help
50 Replies
nobody can help you if you don't explain your problem and share the relevant code
@jIMMACLE
same problem as yesterday
wait ill send picture
It is returning null
Ignore the red bit it is jsut debug
The user things is not working
@jIMMACLE what do you think i should do
i think you should go through your code with the debugger line by line and find the first place it starts going wrong
i did that
the problem is is when i include users odersumbited var becomes null
so the querry is wrong
@jIMMACLE
var
is not the name of a variable, you need to be very detailed and specific when asking for help
we aren't here to do all the work for youok the ordersumbited var
can you show me that it's null in your debugger?
yes i just want to know the problem and possible soultions this project is for fun
yes i will it run it
so with that information where should you look to narrow down the problem?
the problem i believe is the users
cus when i dont include user in the query it work until it gets to adding the user data
the user class is inherited from the identity user the built in one
at this point you should just share your code on github because this is way too confusing to try and figure out this way
ight i dont even have a git hub ill just give up on this
thank you for trying
i just dont get how including the user could cus the whole var to go null
probably because you're not explaining something clearly here
we can't see your code, we have basically nothing to go off of except what you tell us
i will try and narrow down my problem so i can ask you a spefic question.
Hi, I have come to find the problem is that ef cant find/ access User class or it propertys. thefore it is making it null
i feel this could be due to the class being inheirted and the id field coming from the idenity.user built in class.
@jIMMACLE
At this point, I'd just write the data to the console to find which part of that line throws the
null
exception, and then I'd move through that part's process to find out where it specifically went wrong.
I'm no expert though <:shrug_idk:988159170517823550>its the whole varible
how would i do that
Well yes, but
_context
could be null, _context.User
could be null, and either the Id
of the user you're looking for could be null, or you could've accidentally added a null
user to the list.
There are four different places in which it could go wrong, from my perspective._context is the thing i use throught right
it works in other place for eg _context.orders
what would a null user look like
cus i do have user all with id but some blank feilds which i tought i could fill up later
@Yui if _context.User was null how would i fix it and what could cause that
Well, I'm assuming
_context.User
is a container, so it could be null if it was never set to a value.well i have users in the databse it self
Again, I'd just write all of the values to the console, or just set break-points so you know the values of all of the variables, and can therefore locate the source of the error.
i did that
the probelm is this line
Yes, the problem is that line, but something in the line is setting it off.
wait i made it simpler
You need to establish break-points before then to find out which item is null.
You should also consider the possibility that there just isn't a user in that list with that Id
There is in the database
in that line, something is returning
null
, that's all I can tell you.I run debug
All I can say is you should check
_context
, _context.User
, and whether the user exists in the container.How would I do that
Not through any other sources, but just through THOSE variables there.
Break-points or writing to a console.
Where should I add the brake points
Somewhere above where the error is, otherwise you won't receive the values you want.
I can't help you other than that, you have to figure it out on your own.
Ok Iβll run debug and show you the results
Oh ok
I got a question
It should matter what the controller is right
But there is definitely enough information in this chat for you to solve your problem.
I canβt do it anywhere and it should be the same
???
Like I donβt have to be the user controller
I don't know the answer to that, but good luck with your issue
Thank you very much
Is this what you need help with?
This looks like it's null because you haven't executed the line yet.
No it is null after to
You kinda have to help us help you. We don't have access to the project and so we can't debug it for you, nor should we. Given that it's
null
after executing the line, you have two things you can look into pretty easily:
- What is the order ID?
- Is that order ID available in the dataset your context is pulling from?
Without that information, we really can't help much further.
What have you learned in the 5 hours you've been trying to solve this issue?Unknown Userβ’11mo ago
Message Not Public
Sign In & Join Server To View