• Entity Framework 实现in查询


            private Expression<Func<Model.Current.Project, bool>> GetExpressionWhereCurrent(Model.Project obj)
            {
                var where = PredicateExtensionses.True<Model.Current.Project>();
                //单位名称
                @where = (!string.IsNullOrEmpty(obj.vcsgmc)) ? @where.And(p => p.vcsgmc.Contains(obj.vcsgmc)) : @where;
                //工程代号
                @where = !string.IsNullOrEmpty(obj.gcbm)
                             ? (obj.gcbm.IndexOf(",", StringComparison.Ordinal) > -1 && obj.gcbm.Length > 2
                                    ? CurrentGcbmWhere(obj.gcbm)
                                    : @where.And(p => p.gcbm == obj.gcbm))
                             : @where;
                //工程名称
                @where = (!string.IsNullOrEmpty(obj.vcgcmc)) ? @where.And(p => p.vcgcmc.Contains(obj.vcgcmc)) : @where;
                return @where;
            }
            private Expression<Func<Model.Current.Project, bool>> CurrentGcbmWhere(string gcbm)
            {
                var where = PredicateExtensionses.True<Model.Current.Project>();
    
                gcbm = StringFormater.StringCut(gcbm, 2, gcbm.Length - 2);
                var gcbms = gcbm.Split(',');
                @where = @where.And(p => gcbms.Contains(p.gcbm));
                return where;
            }


    注意“Contains”关键字。

  • 相关阅读:
    在jQuery中.bind() .live() .delegate() .on()的区别
    jquery小结测试题
    揭秘子类构造函数执行过程
    过滤器
    实现AJAX的基本步骤
    AJAX 原生态
    java工程师需要学什么
    Java进阶之路
    git入门大全
    轻松学JVM
  • 原文地址:https://www.cnblogs.com/blackice/p/2664177.html
Copyright © 2020-2023  润新知