The problem with the 'name' argument in EF, WinForms

System.ArgumentException: 'The argument 'name' cannot be null, empty or contain only white space.' Let me know, if you need any additional information.
No description
6 Replies
Angius
Angius4mo ago
FYI, if you only need the FullName, a better query would be
string? sotrNam = _repository.Sotrs
.Where(s => s.Id == _sotrId)
.Select(s => s.FullName)
.FirstOrDefault();
string? sotrNam = _repository.Sotrs
.Where(s => s.Id == _sotrId)
.Select(s => s.FullName)
.FirstOrDefault();
Seems the exception happens somewhere else? I don't see anything have a name argument anywhere here
vitaliiklimenko
vitaliiklimenkoOP4mo ago
Exception happens with any of my DbSet objects, but only in this Presentater (I use MVP).
No description
Angius
Angius4mo ago
Could it be that some of the database models you have have non-default constructors?
vitaliiklimenko
vitaliiklimenkoOP4mo ago
It seems, that I've found the error, thank you for feedback, you're kind
No description
Angius
Angius4mo ago
Ah, yeah, that would do it
jcotton42
jcotton424mo ago
@vitaliiklimenko adding onto this, your EF models shouldn’t have constructors at all.
Want results from more Discord servers?
Add your server