必须在mvc中定义MySql参数

时间:2017-04-21 13:33:21

标签: mysql model-view-controller

我在这里有这个代码:

var sql = "select shr_id, shc_id " +
                      "from tbox_operational.shipment_ref " +
                      "inner join tbox_operational.shipment_collo_ref using (shr_id) " +
                      "where shr_insdtm between ?dateTimeFrom";

var parameters = new List<MySqlParameter> {
                                           new MySqlParameter("?dateTimeFrom", dateTimeFrom.ToString("yyyy/MM/dd HH:mm:ss"))                                                            
                                           };

            var query = (from db in context.Database.SqlQuery<ShridsModel>(sql, parameters)
                         select db).ToList();

            return query;

但它让我得到了这个错误:

{"Parameter '?dateTimeFrom' must be defined."}

我也在我的连接字符串中:

server=xxx;user id=runtime;password=xxxx;AllowUserVariables=True;

我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

我已经解决了......

我没有传递参数列表,而是传递每个人,并且他认出了所有