Reputation: 345
I am confused with the error I am getting.
I am trying to return records that have the Month number equal to i
but I recieve the following error.
No overload for method 'ToString' takes 1 arguments
Is there another way to return month numbers from this table
var ColourDates = Model.Color.Any(e => e.StartDate.ToString("MM") == i);
Upvotes: 0
Views: 361
Reputation: 368
When using Nullable
types, you will need to get the value of the variable before use. You will need something like var ColourDates = Model.Color.Any(e => e.StartDate.Value.ToString("MM") == i);
NOTE: This does NOT handle null values. You will get an exception if e.StartDate.Value
is null. I highly recommend using e.StartDate.HasValue
to do a null check before use.
Upvotes: 2