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.推荐这个

  • 相关阅读:
    Codeforces Round #352 (Div. 1) B. Robin Hood (二分)
    Codeforces Round #209 (Div. 2) D. Pair of Numbers (模拟)
    Kattis
    kattis Curious Cupid (莫队算法)
    HYSBZ
    SPOJ NETADMIN
    day26-2 基于TCP协议的套接字编程
    day26-1 TCP三次握手和四次挥手
    day25-2 OSI协议和socket抽象层
    day25-1 网络架构与互联网组成
  • 原文地址:https://www.cnblogs.com/nanxiaoxiang/p/2625499.html
Copyright © 2011-2022 走看看