zoukankan      html  css  js  c++  java
  • 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},注意不管什么类型都不要要加''

  • 相关阅读:
    SpringMVC—对Ajax的处理(含 JSON 类型)(2)
    md5加密(1)
    js生成邀请码(2)
    SpringMVC---依赖注入与面向切面
    初识json
    java集合类(2)
    springmvc与struts2的区别
    模拟14
    NOIP模拟13
    NOIP模拟12
  • 原文地址:https://www.cnblogs.com/wdfrog/p/2830498.html
Copyright © 2011-2022 走看看