zoukankan      html  css  js  c++  java
  • Linq多条件查询

    1.

     public IEnumerable<M_Student> ReadCollegeAndName(String collnum, String name)
            {
                return from s in dc.M_Student
                       where
                          (!String.IsNullOrEmpty(collnum) ? s.CollegeNum.Equals

                        (collnum) : true) &&
                        (!string.IsNullOrEmpty(name) ? s.Name.Contains

                        (name) : true)
                       select s;
            }

    2.利用Linq执行SQL,运用SQL强大的拼接功能

     public string GetSqlString()
            {
                string s = "1=1";
                if (title.Text!="")
                {
                    s += " && title like %" + title.Text + "%";
                }
                if (name.Text!="")
                {
                    s += " && name like %" + name.Text + "%";
                }
                return s;
            }

            public List<T> GetList()
            {
                var l = from a in _db.Plate
                        where GetSqlString()
                        select a;
                return l.ToList<T>();
            }

    3.推荐这个

  • 相关阅读:
    十五、docker的隔离namespace和资源限制cgroup
    十四、docker-compose
    十三、搭建SSL的私有harbor仓库
    帆软常用JS
    oracle_ cursor.executemany
    sql常用语句
    考勤清洗
    JAVA基础教程day03--运算符
    B站视频爬虫
    ES6
  • 原文地址:https://www.cnblogs.com/nanxiaoxiang/p/2625499.html
Copyright © 2011-2022 走看看