使用纯HTML页与js.ajax.Linq实现分页与组合查询的配合使用 <body> <div id="top"><input type="button" id="btn1" class="btn" value="刷新" /></div> <div style="position:relative;text-align:center;heigh…
1.封装实体类 2.写查询方法 //SubjectData类 public List<Subject> Select(string name) { List<Subject> list = new List<Subject>(); cmd.CommandText = "select *from Subject where SubjectName like @a "; cmd.Parameters.Clear(); cmd.Parameters.Add…
界面: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server…
1.封装实体类 2.写查询方法 //SubjectData类 public List<Subject> Select(string name) { List<Subject> list = new List<Subject>(); cmd.CommandText = "select *from Subject where SubjectName like @a "; cmd.Parameters.Clear(); cmd.Parameters.Add…
sql = "select * from Commodity"; hs = new Hashtable(); if (txt_name.Text.Trim() != "") { sql += " where Name like @Name"; hs.Add("@Name", "%" + txt_name.Text.Trim() + "%"); } 一.通过字符串操作,查看之前是否有Whe…
一.linq高级查 1.模糊查(包含) 1 public List<User> Select(string name) 2 { 3 return con.User.Where(r =>r.UserName.Contains(name)).ToList(); 4 } 2.查开头 public List<User> Select(string name) { return con.User.Where(r => r.UserName.StartsWith(name)).To…
一.分页 1.写查询方法: public List<Student> Select(int PageCount, int PageNumber) {//PageCount为每页显示条数,PageNumber为当前第几页 List<Student> list = new List<Student>(); cmd.CommandText = ))+" Code from Student)"; conn.Open(); SqlDataReader dr =…
组合查询 protected void Button1_Click(object sender, EventArgs e) { //默认查询所有,返回的是Table类型,转换成IQueryAble类型. var query1 = this._Contex.car.AsQueryable(); var query2 = this._Contex.car.AsQueryable(); var query3 = this._Contex.car.AsQueryable(); //进一步判断查询,根据输…
1.首先使用Linq连接数据库,并扩展属性 public partial class User { public string SexStr { get { string end = "<暂无>"; if (this._Sex != null) { end = Convert.ToBoolean(this._Sex) ? "男" : "女"; } return end; } } public bool SexStr1 { get {…
一.linq高级查 1.模糊查(字符串包含) 1 public List<User> Select(string name) 2 { 3 return con.User.Where(r =>r.UserName.Contains(name)).ToList(); 4 } 2.查开头(StartsWith,以XX开头) public List<User> Select(string name) { return con.User.Where(r => r.UserName…