String s = String.Format("select * from Price_ItemDepts where FeeDeptID={0}{1}{2}",
$"'{deptID}'",
string.IsNullOrEmpty(categoryID) ? "" : $"' and FeeDeptID in (select distinct 项目编码 from Price_Items where 收费类别编码 ={categoryID}'",
string.IsNullOrEmpty(itemID) ? "" : $"' and 项目编码={itemID}'");
return View(db.Price_ItemDepts.SqlQuery(s).ToList());
注意引号的应用,?类似 其他语言的 iif 函数
标签:itemID,语句,编码,插值,Price,FeeDeptID,字符串,ItemDepts From: https://www.cnblogs.com/Biyuanguang/p/17092463.html