mejobloggs
EF/Linq select all columns of main table, but only some cols of joined table?
I find myself often wanting to select all of a table, but very limited columns of joined tables.
Is it possible to do without explicitly listing all columns?
Example:
56 replies
✅ Easier way to "mark" a class as a different "type" without having to create a new class?
Sorry about the title, I'm not sure of the correct terminology
Here's my scenario
I have a basic class
Which is fine, I can display the reason for failure to the user.
But I notice when trying to create some unit tests, I'm trying to test for specific failures, and the test might pass because of a different failure... which isn't a proper test then.
The test could say
Assert.IsTrue(validation.ErrorMessage == "Failure because Reason 1")
But then the test would break if I updated the error message.
I could have an IValidationResult, then have e.g 10 different classes all exactly the same, inheriting from IValidationResult
Then my test could say (pseudocode)
Assert.IsTrue(validation is Reason1ValidationResult)
That would be less fragile which is good, but then I have to create a bunch of identical classes (except for the name)
Is there a better/simpler way to do this?7 replies