zoukankan      html  css  js  c++  java
  • 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”关键字。

  • 相关阅读:
    数据类面试题
    java二进制文件复制
    String源码
    集合类题目
    OBJ-C
    java文件(文件夹)操作
    java中输入方式Scanner和BufferedReader
    二次分发举例
    Eclipse常用快捷键
    c#获取新浪微博登录cookie
  • 原文地址:https://www.cnblogs.com/blackice/p/2664177.html
Copyright © 2011-2022 走看看