• ef 高级操作


    一:动态拼接条件查询

    var expression = PredicateBuilder.True<OQC_MES_INF_UL_QMS_OFFLINE>();
    SYS_ROLES_CONFIG rule = context.SysRolesConfig.Single(t => t.ORG_ID == orgid&&t.STATE=="A");
    
    StringBuilder sb = new StringBuilder();
    sb.Append("该机身条码在与当前抽检");
    if (!string.IsNullOrEmpty(rule.SYS_PARMS1)) {
    //同生产工单
    expression = expression.And(a => a.MO_NAME == model.WORK_ORDER_ID);
    sb.Append("同生产工单、");
    }
    
      int count = context.OQC_MES_INF_UL_QMS_OFFLINE.Get(expression).Count();
    

      

    二:左连接

    var result1 = from a in context.OQC_ASS_PARTS_V_INF
    join b in context.INV_MITEM on a.PRIMARY_ITEM_ID equals b.CODE
    where a.STATE == StateConverter.Active && a.ORG_ID == ORG_ID && a.ORG_ID == b.ORG_ID && a.WIP_ENTITY_NO == WORK_ORDER_ID
    select new
    {
    WIP_ENTITY_ID = a.WIP_ENTITY_ID,
    PROID = a.PRIMARY_ITEM_NAME,
    WIP_ENTITY_NO = a.WIP_ENTITY_NO,
    START_QUANTITY = a.START_QUANTITY,
    EATTRIBUTE1 = b.EATTRIBUTE1,
    COMPLETE_DATE = a.SCHEDULED_COMPLETION_DATE,
    SCHEDULE_GROUP = a.SCHEDULE_GROUP_NAME,
    PRODUCTION_LINE = a.EATTRIBUTE1
    };
    var result2 = from a in context.OQC_ASS_PARTS_V_INF
    join c in context.OQC_OMS_IF_QMS_ORDERINFO_V_INF on a.PRIMARY_ITEM_NAME equals c.MRP_ITEM_CODE
    where a.STATE == StateConverter.Active && a.ORG_ID == ORG_ID && a.ORG_ID == c.ORG_ID && a.WIP_ENTITY_NO == WORK_ORDER_ID
    select new
    {
    WIP_ENTITY_ID = a.WIP_ENTITY_ID,
    CONSUME_COUNTRY = c.CONSUME_COUNTRY,
    CUSTOMER_NAME = c.CUSTOMER_NAME,
    CUSTOMER_CODE = c.CUSTOMER_CODE
    };
    var result3 = from aa in result1
    join bb in result2 on aa.WIP_ENTITY_ID equals bb.WIP_ENTITY_ID
    into cc
    from bb in cc.DefaultIfEmpty()
    select new
    {
    //产品编码
    PROID = aa.PROID,
    //生产工单
    WIP_ENTITY_NO = aa.WIP_ENTITY_NO,
    //工单数量
    START_QUANTITY = aa.START_QUANTITY,
    //产品型号
    EATTRIBUTE1 = aa.EATTRIBUTE1,
    //完工时间
    COMPLETE_DATE = aa.COMPLETE_DATE,
    //车间
    SCHEDULE_GROUP = aa.SCHEDULE_GROUP,
    //客户订单号
    CUSTOMER_CODE = bb.CUSTOMER_CODE,
    //客户名称
    CUSTOMER_NAME = bb.CUSTOMER_NAME,
    //销往地
    CONSUME_COUNTRY = bb.CONSUME_COUNTRY,
    //作业产线信息
    PRODUCTION_LINE=aa.PRODUCTION_LINE
    };
    var rs = result3.FirstOrDefault();
    

      

  • 相关阅读:
    智能算法:遗传算法
    matlab中画一条折线时怎样显示出每个点折点的数值
    灰色系统模型
    图论中TSP问题的LINGO求解与应用
    图论中最短路算法与程序实现
    图论中最优树问题的LINGO求解
    Hexo博客NexT主题美化之评论系统
    IN612L支持2.4G及蓝牙5.0全协议的SoC芯片替换NRF52832/NRF52840
    超低功耗蓝牙5.0芯片PHY6202替代NRF51822/NRF51802/NRF52832
    NRF51802多协议低功耗蓝牙/2.4G系统级芯片对比NRF51822差异
  • 原文地址:https://www.cnblogs.com/chenli0513/p/5363452.html
Copyright © 2020-2023  润新知