我已经阅读了很多关于此主题的帖子,但仍然无法使用我的代码。
不确定postgreSQL是否改变了事情......
这就是我所拥有的(可能是显而易见的)不工作:
string mySelectQuery = @"select distribution_stop_information.unique_id_no as stop_unique_id_no,
distribution_line_items.unique_id_no as line_unique_id_no, stop_name, stop_address,route_code AS RouteCode, customer_reference,
distribution_line_items.datetime_created, rma_number from distribution_stop_information join distribution_line_items on
distribution_line_items.unique_id_no = distribution_stop_information.unique_id_no
where distribution_line_items.datetime_created > '2/22/2017' and customer_no = :CustNo";
var dbCommand = db.CreateCommand();
var para = dbCommand.CreateParameter();
para.ParameterName = "CustNo";
para.Value = 91000;
//what do I put HERE to have it pass a parameter to replace the :CustNo???
var allStops = (List<stopsData>)db.Query<stopsData>(mySelectQuery,para);
以上产生错误:参数&#39; CustNo&#39;不见了。
目前,这是我正在做的事情,直到我得到更好的解决方案:
string stops_query = $@"select distribution_stop_information.unique_id_no as stop_unique_id_no,
distribution_line_items.unique_id_no as line_unique_id_no,
stop_name, stop_address,
rma_original_unique_id,
route_code,
customer_reference,
distribution_line_items.datetime_created as DateTimeCreated_LI,
rma_number from distribution_stop_information
join distribution_line_items on distribution_line_items.unique_id_no = distribution_stop_information.unique_id_no
where distribution_line_items.datetime_created > '{dateToCheck}' and customer_no = {TNGCustNo}";