EF参数化查询
string cmdText = @"select FGPartNO PartNO,p_FGName PartName,
partno MNo,p_partnoName MName,
partnoqty Qty, UM [Unit]
from singleBom Where Used='Y' And FGPartNo={0}";
string key=partNo.Trim().ToLower();
List<BOMInfo> bom = null;
if(!BOMDic.ContainsKey(key))
{
using (var ctx = DBFactory.NewCtx())
{
var list= ctx.ExecuteStoreQuery<BOMInfo>(cmdText, partNo).ToList();
if (list.Count == 0) throw new Exception("未创建物料{0}的BOM记录!");
BOMDic[key] = list;
}
}
bom = BOMDic[key];
return bom;
类似String.Format 使用{x},注意不管什么类型都不要要加''