1.以开头查

public List<Car> Select1(string a){

return con.Car.Where(r => r.Name.StartsWith(a)).ToList();
}

2.以结尾查

public List<Car> Select2(string a)

{
return con.Car.Where(r => r.Name.EndsWith(a)).ToList();
}

3.最大值

public string Max()

{
return con.Car.Max(r => r.Price).ToString();
}

4.最小值

public string Min()

{
return con.Car.Min(r => r.Price).ToString();
}

5.总和

public string Sum()
{
return con.Car.Sum(r => r.Price).ToString();
}

6.平均值

public string avg()
{
return con.Car.Average(r => r.Price).ToString();
}

7.升序

public List<Car> ss()
{
return con.Car.OrderBy( r =>r.Price).ToList();
}

8.降序

public List<Car> s()
{
return con.Car.OrderByDescending(r => r.Price).ToList();
}

9.组合分页查询

    public List<Car> Selecta(int d, string a, string b, string c)
{
List<Car> list = new List<Car>();
list = con.Car.ToList();
if (a != "")
{
List<Car> list1 = con.Car.Where(r => r.Code.Contains(a)).ToList(); list = list.Intersect(list1).ToList();
}
if (b != "")
{
List<Car> list1 = con.Car.Where(r => r.Name.Contains(b)).ToList(); list = list.Intersect(list1).ToList();
}
if (c != "")
{
List<Car> list1 = con.Car.Where(r => r.Brand.Contains(c)).ToList(); list = list.Intersect(list1).ToList();
}
return list.Skip((d-1-1) * PageCount).Take(PageCount).ToList(); } int PageCount = 6;
public List<Car> start()
{
return con.Car.Skip(0 * PageCount).Take(PageCount).ToList();
}
public List<Car> prev(string a)
{
return con.Car.Skip((Convert.ToInt32(a) - 1 - 1) * PageCount).Take(PageCount).ToList();
}
public List<Car> next(string a)
{
return con.Car.Skip(Convert.ToInt32(a) * PageCount).Take(PageCount).ToList();
}
public List<Car> end()
{
return con.Car.Skip((max() - 1) * PageCount).Take(PageCount).ToList();
} private int max()
{
int count = new CarData().Select().Count; double aa = count / (PageCount * 1.0); return Convert.ToInt32(Math.Ceiling(aa));
}
}

  

void LinkButton4_Click(object sender, EventArgs e)
{
Repeater1.DataSource = new CarData().end();
Repeater1.DataBind();
Label2.Text = max().ToString();
} private int max()
{
int count = new CarData().Select().Count; double aa = count / (PageCount * 1.0); return Convert.ToInt32(Math.Ceiling(aa));
}
void LinkButton3_Click(object sender, EventArgs e)
{
if (Convert.ToInt32(Label2.Text) < max())
{
int a = Convert.ToInt32(Label2.Text) + 1;
Repeater1.DataSource = new CarData().next(Label2.Text);
Repeater1.DataBind();
Label2.Text = a.ToString();
}
else
{
return;
} } void LinkButton2_Click(object sender, EventArgs e)
{ if (Convert.ToInt32(Label2.Text) > 1)
{
int a = Convert.ToInt32(Label2.Text) - 1;
Repeater1.DataSource = new CarData().prev(Label2.Text);
Repeater1.DataBind();
Label2.Text = a.ToString();
}
else
{
return;
}
} void LinkButton1_Click(object sender, EventArgs e)//首页
{
Repeater1.DataSource = new CarData().start();
Repeater1.DataBind();
Label2.Text = "1";
} void Button13_Click(object sender, EventArgs e)
{
Label2.Text = "1";
int a = Convert.ToInt32(Label2.Text) + 1;
Repeater1.DataSource = new CarData().Selecta(a,TextBox3.Text, TextBox4.Text, TextBox5.Text);
Repeater1.DataBind(); int count = new CarData().Select().Count; Label3.Text = Math.Ceiling(Convert.ToDouble(count) / PageCount).ToString(); }

  

LinkQ 组合查询与分页的更多相关文章

  1. Web 组合查询加 分页

    使用ADO.NET 数据访问技术制作web端组合查询加分页的功能关键在于查询SQL语句的拼接 以Car 表为例 每页显示3条数据 数据访问类使用查询方法,tsql 查询的连接字符串,查询的参数放到Ha ...

  2. webform组合查询和分页

    1.组合查询(1)数据访问类 //参数1:SQL语句 参数2:哈希表public List<Users> chas(string s,Hashtable has) { List<Us ...

  3. LINQ 小项目【组合查询、分页】

    使用 linq 在网页上对用户信息增删改,组合查询,分页显示 using System; using System.Collections.Generic; using System.Linq; us ...

  4. Linq组合查询与分页组合查询结合

    1.组合查询 <div>姓名:<asp:TextBox ID="T1" runat="server"></asp:TextBox& ...

  5. LinQ 组合查询与分页

    1.以开头查 public List<Car> Select1(string a){ return con.Car.Where(r => r.Name.StartsWith(a)). ...

  6. spring boot jpa 多条件组合查询带分页的案例

    spring data jpa 是一个封装了hebernate的dao框架,用于单表操作特别的方便,当然也支持多表,只不过要写sql.对于单表操作,jpake可以通过各种api进行搞定,下面是一个对一 ...

  7. LINQ 组合查询 和分页查询的使用

    前端代码 <%@ Page Language="C#" AutoEventWireup="true" Debug="true" Cod ...

  8. linq分页组合查询

    一.linq高级查 1.模糊查(字符串包含) 1 public List<User> Select(string name) 2 { 3 return con.User.Where(r = ...

  9. Webform(Linq高级查、分页、组合查询)

    一.linq高级查 1.模糊查(包含) 1 public List<User> Select(string name) 2 { 3 return con.User.Where(r => ...

随机推荐

  1. HTML中的attribute和property

    一.概述 attribute和property是常常被弄混的两个概念. 简单来说,property则是JS代码里访问的: document.getElementByTagName('my-elemen ...

  2. 【python】如何安装BeautifulSoup4

    在cmd窗口输入 pip install beautifulsoup4,如下: C:\Users\horn1\Desktop\python\3>pip install beautifulsoup ...

  3. Android Activity的生命周期的几个方法介绍

    onCreate():创建Activity调用,用于Activity的初始化,还有个Bundle类型的参数,可以访问以前存储的状态. onStart():Activity在屏幕上对用户可见时调用 on ...

  4. angularjs中使用$scope.$watch监控对象模型的变化

    如果对象模型发生变化时,可以使用$scope.$watch监控变化 <html ng-app="myApp"> <head> <title>an ...

  5. SQL语言 之 数据查询

    在Oracle 数据库中,SELECT 语句的基本语法为: SELECT [ALL|DISTINCT] column_name [,expression...] FROM table1_name [, ...

  6. C# Dictionary通过value获取对应的key值[转发]

    1:最直白的循环遍历方法,可以分为遍历key--value键值对以及所有的key两种表现形式 2:用Linq的方式去查询(当然了这里要添加对应的命名空间 using System.Linq) 如下为一 ...

  7. 关于视频YUV

    这里有一篇摘自MSDN的文章.介绍了YUV视频数据格式. About YUV Video Digital video is often encoded in a YUV format. This ar ...

  8. js 动态创建变量

      js 动态创建变量 CreationTime--2018年7月2日15点04分 Author:Marydon 1.实现方式 通过eval()实现 2.代码实现 /** * 声明一个函数 * @ex ...

  9. linux sort 、uniq 命令

    以文件的每行为单位,从左往右依次按ascii码进行比较 sort sort.txt #默认为升序 -u:去除重复行 sort -u sort.txt -r:降序排列 sort -r sort.txt ...

  10. Maven构建项目时index.jsp文件报错

    错误为:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 原 ...