zoukankan      html  css  js  c++  java
  • Nullable object must have a value

    有一个linq查询,由inner join改成left join, 对于有空值,就会出现Nullable object must have a value 的错误.

    原来的查询:

     var qry =
                from c in _context.CCC
                join f in _context.FFF .Where(t=>t.IsActive==true)
                on  new { c.ProjectId, cat = c.Category } equals new { f.ProjectId, cat = f.Category }
                where  c.IsActive == true 
                select
                new
                {
                    c.Id,
                    f.category
             }

    left join, select的字段做null判断

     var qry =
                from c in _context.CCC
                join f in _context.FFF .Where(t=>t.IsActive==true)
                on  new { c.ProjectId, cat = c.Category } equals new { f.ProjectId, cat = f.Category }
                into temp
                from tt in temp.DefaultIfEmpty()
                where  c.IsActive == true 
                select
                new
                {
                    c.Id,
                    category=(f==null)?'':f.category
             }
  • 相关阅读:
    win10使用WampServer部署magento
    JavaScript的this详解
    jQuery的css
    jQuery.cssHooks
    jQuery属性
    jQuery选择器
    ajax中的stasus错误详解
    ajax
    js数组中的注意
    js的严格模式
  • 原文地址:https://www.cnblogs.com/zitjubiz/p/10768967.html
Copyright © 2011-2022 走看看