这是我的代码片段:
#region Validate and prepare parameters
if (month > 12)
{
throw new ArgumentException("Value of 'month' could not be greater than 12.");
}
int yearEnd = year;
int monthEnd = 0;
if (month != 12)
{
monthEnd = month + 1;
}
else
{
monthEnd = 1;
yearEnd = year + 1;
}
#endregion
MyModelDataContext context = new MyModelDataContext();
string sql =
@"select SUM(ORDERQTY * MULTIPLIER) AS VOL_USD
from Executions with (nolock)
where TRANSACTTIME >= '{0}-{1}-01 00:00:00'
and TRANSACTTIME < '{2}-{3}-01 00:00:00'
and MTCONTEXT in (5,6)
and ORDERQTY > 0
AND SOURCE = 'INTMT'
and LEFT(SYMBOL, 3) = 'USD'";
decimal usd___Sum = context.ExecuteQuery<decimal>(sql, year, month, yearEnd, monthEnd).First();
我得到了例外:
从字符串转换日期和/或时间时转换失败。
当我调用ExecuteQuery方法时。year 的值为 2013,month 的值为 9。我做错了什么?
提前致谢。