The procedure takes two "date strings" as parameters. I was using this extension method to convert my DateTime
s, causing issues due to single-digit days/months:
public static string ToDateParameter(this DateTime dt)
{
//Format of procedure's parameters: MMDDYYYY
return dt.Month.ToString() + dt.Day.ToString() + dt.Year.ToString();
}
Updated to this and no more errors:
public static string ToDateParameter(this DateTime dt)
{
string day;
string month;
/*
* Format of procedure's parameters: MMDDYYYY
* Procedure expects string of 8 characters for dates; adding 0's in front of single-digit days & months.
*/
day = dt.Day.ToString().Length == 1 ? "0" + dt.Day.ToString() : dt.Day.ToString();
month = dt.Month.ToString().Length == 1 ? "0" + dt.Month.ToString() : dt.Month.ToString();
return month + day + dt.Year.ToString();
}
Initially, I didn't think anything of checking my parameters due to EF errors like:
System.Data.EntityCommandExecutionException: The data reader is incompatible with the specified `Property`. A member of the type, `Property`, does not have a corresponding column in the data reader with the same name.
Update: I did not write the SP and disagree with those parameters. Still, I did not expect to see EF errors rather than DB2 sending me errors back.