C
C#2mo ago
Beluga XD

Need help with AspNetCore and GUID.

Well I have got the following code for my register method in my webapi (Shown on first image. It is pretty simple). I am running my xUnit test for this method (everything is good) but it seems that I can't access my user.Id normally (I am returning it via "return Ok(user.Id);" line). Somehow debugger shows me that I have got two Id properties, one is actual Id and another just filled with zeros (shown on second photo). I would be grateful if someone explains me what is the problem with them and how can I access actual Id
No description
No description
17 Replies
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Beluga XD
Beluga XDOP2mo ago
May I ask what is the problem with Guid as an id? I saw just people in youtube use them so I was thinking it is default approach
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Beluga XD
Beluga XDOP2mo ago
Oh you mean that I won't use Id when I look for users? That what you mean?
MODiX
MODiX2mo ago
TeBeCo
REPL Result: Success
(
Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid())
(
Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid(),Guid.NewGuid())
Result: ValueTuple<Guid, Guid, Guid, Guid, Guid, Guid, Guid, ValueTuple<Guid, Guid, Guid>>
{
"item1": "c3375f83-0e0d-4c8b-936d-0eb6deab3fe5",
"item2": "ada43a9e-363e-45d4-82b6-821f65ab03ac",
"item3": "3985b5dd-158e-41e8-889b-9511e1d88469",
"item4": "bb260775-38d3-446f-9572-afefccae1364",
"item5": "f546f923-b879-4dcf-808e-3c627aceb7c7",
"item6": "1cc12fee-4821-4626-be3f-42dfed711e53",
"item7": "72cca71a-0cb3-4f27-bdfb-eac81d6222c1",
"rest": {
"item1": "956d8c78-46d1-42a5-8144-63c787ba2aea",
"item2": "aff4d76b-8160-413d-9e0b-df7aadba35a6",
"item3": "fa91fd81-df2b-410e-8212-1eb929950b89"
}
}
{
"item1": "c3375f83-0e0d-4c8b-936d-0eb6deab3fe5",
"item2": "ada43a9e-363e-45d4-82b6-821f65ab03ac",
"item3": "3985b5dd-158e-41e8-889b-9511e1d88469",
"item4": "bb260775-38d3-446f-9572-afefccae1364",
"item5": "f546f923-b879-4dcf-808e-3c627aceb7c7",
"item6": "1cc12fee-4821-4626-be3f-42dfed711e53",
"item7": "72cca71a-0cb3-4f27-bdfb-eac81d6222c1",
"rest": {
"item1": "956d8c78-46d1-42a5-8144-63c787ba2aea",
"item2": "aff4d76b-8160-413d-9e0b-df7aadba35a6",
"item3": "fa91fd81-df2b-410e-8212-1eb929950b89"
}
}
Compile: 215.179ms | Execution: 22.803ms | React with ❌ to remove this embed.
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Beluga XD
Beluga XDOP2mo ago
Oh I see
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Beluga XD
Beluga XDOP2mo ago
Well fair point I understand now
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Beluga XD
Beluga XDOP2mo ago
Thank you for your explanation, will redo my db in that case (I used only Guids for ids in my dbs)
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Beluga XD
Beluga XDOP2mo ago
Oh I see, quite convinient in that case, I wanted to ask about it, because on my photo Id provided by AspNetCore was already in string
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Beluga XD
Beluga XDOP2mo ago
I see, thank you for your explanation, it really helped me
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX2mo ago
If you have no further questions, please use /close to mark the forum thread as answered
Want results from more Discord servers?
Add your server