C
C#โ€ข8mo ago
Spugnetta

Help! records & Ef

Hello guys ๐Ÿ™‚ im trying to use a record for a value object owned by my enetity but when updating i get exceptions, below the screens of my code
No description
No description
No description
No description
15 Replies
Angius
Angiusโ€ข8mo ago
Yeah, records don't really work with EF Their properties don't have setters, only initializers
Unknown User
Unknown Userโ€ข8mo ago
Message Not Public
Sign In & Join Server To View
Parpil
Parpilโ€ข8mo ago
You indeed can make record mutable by overwriting with { get; set; } , however @TeBeCo , can you explain what does request keyword does?
Unknown User
Unknown Userโ€ข8mo ago
Message Not Public
Sign In & Join Server To View
Parpil
Parpilโ€ข8mo ago
Oh. I got scared in the moment, scraping web to see what it does, thinking it is some new feature in preview ๐Ÿ˜… non-nullable > non-default ๐Ÿ™‚
Unknown User
Unknown Userโ€ข8mo ago
Message Not Public
Sign In & Join Server To View
Parpil
Parpilโ€ข8mo ago
Address address = new () { Foo = null };

public record Address
{
public required string? Foo { get; set; }
}
Address address = new () { Foo = null };

public record Address
{
public required string? Foo { get; set; }
}
This is valid
Unknown User
Unknown Userโ€ข8mo ago
Message Not Public
Sign In & Join Server To View
Parpil
Parpilโ€ข8mo ago
Oh understandable I thought you were thalking about required making it non-nullable. Thanks.
Unknown User
Unknown Userโ€ข8mo ago
Message Not Public
Sign In & Join Server To View
Spugnetta
SpugnettaOPโ€ข8mo ago
hi thx for the answer @TeBeCo, i still have the same problem even changing adress into a class, maybe im doing something wrong with the executedupdate setters?
No description
Spugnetta
SpugnettaOPโ€ข8mo ago
No description
Spugnetta
SpugnettaOPโ€ข8mo ago
if i do it this way it works but damn, this seems a little to verbose no?
No description
Unknown User
Unknown Userโ€ข8mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server