• EF LEFT JON 关联查找


    var query = (from a in context.OQC_INSPECTION_SAMPLE.Where(expression).Where(a => context.OQC_INSPECTION_SAMPLE_ITEM.Where(b => b.SAMPLE_INSPECTION_ID == a.ID).Where(expression2).Any())
                                         join b in context.OQC_INSP_SAMPLE_RPT.Where(expression1)
                                             on a.ID equals b.REF_SAMPLE_ID into gc
    
                                         where a.STATE == StateConverter.Active && a.ORG_ID == standard.ORG_ID  
                                         from gci in gc.DefaultIfEmpty()
                                         select new
                                         {
    
                                             Str_Array = a.ID + "#" + a.PROD_ID + "#" + a.INSPECTION_NO + "#" + a.WORK_ORDER_ID + "#" + a.PROD_MODEL_ID + "#" + a.TEAM_GROUP,
                                             a.APPROVER,
                                             a.BARCODE,
                                             a.BARCODE_COMPLETION_TIME,
                                             a.BATCH_NO,
                                             a.CLIENT_NAME,
                                             a.CLIENT_ORDER_ID,
                                             a.COMPLETE_COUNT,
                                             a.DATETIME_CREATED,
                                             a.DATETIME_MODIFIED,
                                             a.DATETIME_REPORT_GENERATED,
                                             a.ELT_RESULT,
                                             a.FAIL_COUNT,
                                             a.FAIL_DESC,
                                             a.FEATURES_LEVEL,
                                             a.GROSS_WEIGHT,
                                             a.ID,
                                             a.INSPECTION_COUNT,
                                             a.INSPECTION_LEVEL,
                                             a.INSPECTION_NO,
                                             a.INSPECTION_RESULT,
                                             a.INSPECTION_TIME,
                                             a.INSPECTOR,
                                             a.IS_CHANGESTD1,
                                             a.IS_INSPECTOR,
                                             a.MANTISSA,
                                             a.NET_WEIGHT,
                                             a.ORG_ID,
                                             a.PROD_DESC,
                                             a.PROD_MODEL_ID,
                                             a.PROD_ID,
                                             a.PRODUCTION_END_TIME,
                                             a.PRODUCTION_LINE,
                                             a.PRODUCTION_START_TIME,
                                             a.RECEIPTS_TIME,
                                             a.RECTIFY,
                                             a.RECTIFY_OPINION,
                                             a.REMADE_INSPECTION_NO,
                                             a.REMADE_REPORT_NO,
                                             a.REMADE_RESULT,
                                             a.REMARK,
                                             a.SAMPLE_COUNT,
                                             a.SAMPLING_PERCENT,
                                             a.SAMPLING_STANDARD,
                                             a.SN,
                                             a.SOLD_TO,
                                             a.SOLD_TO_DISPLAY,
                                             a.STANDARD_NAME,
                                             a.STATE,
                                             a.STATUS,
                                             a.STOP_PRODUCTION,
                                             a.STRICT_LEVEL,
                                             a.TEAM_GROUP,
                                             a.USER_CREATED,
                                             a.USER_CREATED_NAME,
                                             a.USER_MODIFIED,
                                             a.USER_MODIFIED_NAME,
                                             a.WORK_ORDER_ID,
                                             a.WORK_ORDER_QTY,
                                             a.WORKSHOP,
                                             a.PRODUCT_INFO,
                                             rpt_id =gci==null?"": gci.ID,
                                             joinstate = gci==null?"N":(gci.JOINSTATE == null ? "N" : gci.JOINSTATE),
                                         });
                            totalRecords = query.Count();
                            return query.OrderByDescending(a => new { a.DATETIME_CREATED, a.DATETIME_MODIFIED })
                                        .Skip(viewQueryModel.start).Take(viewQueryModel.length).ToList();
                        }
    

      

  • 相关阅读:
    SQLite基础-7.子句(一)
    SQLite基础-8.子句(二)
    SQLite基础-6.运算符
    SQLite基础-5.数据操作语言
    SQLite基础-4.数据定义语言(DDL)
    SQLite基础-3.语法与数据类型
    IDEA操作之FileHeager设置
    IDEA操作之test case coverage的方法
    IDEA插件之JavaDoc
    IDEA插件之JProfiler
  • 原文地址:https://www.cnblogs.com/chenli0513/p/5474474.html
Copyright © 2020-2023  润新知