C
C#β€’6mo ago
πŸ™ˆ

have a class based of identity user. however when I try to find a user it returns null

Help
50 Replies
Jimmacle
Jimmacleβ€’6mo ago
nobody can help you if you don't explain your problem and share the relevant code
πŸ™ˆ
πŸ™ˆβ€’6mo ago
@jIMMACLE same problem as yesterday wait ill send picture
πŸ™ˆ
πŸ™ˆβ€’6mo ago
No description
πŸ™ˆ
πŸ™ˆβ€’6mo ago
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
Jimmacle
Jimmacleβ€’6mo ago
i think you should go through your code with the debugger line by line and find the first place it starts going wrong
πŸ™ˆ
πŸ™ˆβ€’6mo ago
i did that the problem is is when i include users odersumbited var becomes null so the querry is wrong @jIMMACLE
Jimmacle
Jimmacleβ€’6mo ago
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 you
πŸ™ˆ
πŸ™ˆβ€’6mo ago
ok the ordersumbited var
Jimmacle
Jimmacleβ€’6mo ago
can you show me that it's null in your debugger?
πŸ™ˆ
πŸ™ˆβ€’6mo ago
yes i just want to know the problem and possible soultions this project is for fun yes i will it run it
πŸ™ˆ
πŸ™ˆβ€’6mo ago
No description
πŸ™ˆ
πŸ™ˆβ€’6mo ago
No description
Jimmacle
Jimmacleβ€’6mo ago
so with that information where should you look to narrow down the problem?
πŸ™ˆ
πŸ™ˆβ€’6mo ago
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
Jimmacle
Jimmacleβ€’6mo ago
at this point you should just share your code on github because this is way too confusing to try and figure out this way
πŸ™ˆ
πŸ™ˆβ€’6mo ago
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
Jimmacle
Jimmacleβ€’6mo ago
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
πŸ™ˆ
πŸ™ˆβ€’6mo ago
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
πŸ™ˆ
πŸ™ˆβ€’6mo ago
No description
πŸ™ˆ
πŸ™ˆβ€’6mo ago
i feel this could be due to the class being inheirted and the id field coming from the idenity.user built in class. @jIMMACLE
Yui
Yuiβ€’6mo ago
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>
πŸ™ˆ
πŸ™ˆβ€’6mo ago
its the whole varible how would i do that
Yui
Yuiβ€’6mo ago
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.
πŸ™ˆ
πŸ™ˆβ€’6mo ago
_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
Yui
Yuiβ€’6mo ago
Well, I'm assuming _context.User is a container, so it could be null if it was never set to a value.
πŸ™ˆ
πŸ™ˆβ€’6mo ago
well i have users in the databse it self
Yui
Yuiβ€’6mo ago
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.
πŸ™ˆ
πŸ™ˆβ€’6mo ago
i did that the probelm is this line
Yui
Yuiβ€’6mo ago
Yes, the problem is that line, but something in the line is setting it off.
πŸ™ˆ
πŸ™ˆβ€’6mo ago
wait i made it simpler
Yui
Yuiβ€’6mo ago
You need to establish break-points before then to find out which item is null.
πŸ™ˆ
πŸ™ˆβ€’6mo ago
No description
Yui
Yuiβ€’6mo ago
You should also consider the possibility that there just isn't a user in that list with that Id
πŸ™ˆ
πŸ™ˆβ€’6mo ago
There is in the database
Yui
Yuiβ€’6mo ago
ASshrug02 in that line, something is returning null, that's all I can tell you.
πŸ™ˆ
πŸ™ˆβ€’6mo ago
I run debug
Yui
Yuiβ€’6mo ago
All I can say is you should check _context, _context.User, and whether the user exists in the container.
πŸ™ˆ
πŸ™ˆβ€’6mo ago
How would I do that
Yui
Yuiβ€’6mo ago
Not through any other sources, but just through THOSE variables there. Break-points or writing to a console.
πŸ™ˆ
πŸ™ˆβ€’6mo ago
Where should I add the brake points
Yui
Yuiβ€’6mo ago
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.
πŸ™ˆ
πŸ™ˆβ€’6mo ago
Ok I’ll run debug and show you the results Oh ok I got a question It should matter what the controller is right
Yui
Yuiβ€’6mo ago
But there is definitely enough information in this chat for you to solve your problem.
πŸ™ˆ
πŸ™ˆβ€’6mo ago
I can’t do it anywhere and it should be the same ??? Like I don’t have to be the user controller
Yui
Yuiβ€’6mo ago
catshrug I don't know the answer to that, but good luck with your issue
πŸ™ˆ
πŸ™ˆβ€’6mo ago
Thank you very much
Hazel πŸŒŠπŸ’ƒ
Is this what you need help with? This looks like it's null because you haven't executed the line yet.
πŸ™ˆ
πŸ™ˆβ€’6mo ago
No it is null after to
Hazel πŸŒŠπŸ’ƒ
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
Unknown Userβ€’6mo ago
Message Not Public
Sign In & Join Server To View