获取列表信息包括简单的获取列表信息、条件查询、脚本查询、分页查询、使用查询脚本、使用储存过程查询等示例
ListContents
列表信息——简单示例@条件查询+排序
示例
public ListList_Test() {
SetSql(new DataObject.Param.Filter()
{
Mark = "like",
Value = new LotteryModel() { Lot_title = "140823" }
});
Sql.Orders = new DataObject.Param.Order[]{
new DataObject.Param.Order(){
Type = DataObject.Enum.OrderBy.Desc,
Value = new LotteryModel(){ Lot_id = 1 }
}
};
return base.List();
}
SetSql(new DataObject.Param.Filter()
{
Mark = "like",
Value = new LotteryModel() { Lot_title = "140823" }
});
Sql.Orders = new DataObject.Param.Order[]{
new DataObject.Param.Order(){
Type = DataObject.Enum.OrderBy.Desc,
Value = new LotteryModel(){ Lot_id = 1 }
}
};
return base.List();
}
列表信息——简单示例@脚本查询
示例
string sql = "select * from [Lottery] where lot_title like '%140823%'order by lot_id desc";
Listlist = new LotteryModel().List(sql, System.Data.CommandType.Text);
Listlist = new LotteryModel().List(sql, System.Data.CommandType.Text);
列表信息——分页示例
示例
public ListList(DateTime date_begin,DateTime date_end) {
//设置查询条件
date_begin = date_begin.AddDays(-1);
string condition = string.Format("where setDate between '{0}' and '{1}'", date_begin, date_end);
if (this.Lot_platform > -1) condition += " and lot_platform=" + this.Lot_platform;
if (this.Lot_type > -1) condition += " and lot_type=" + this.Lot_type;
//condition += " and lot_id<5375";
//获取数据
return List(new DataObject.Param.Page(){
Count = 1,
Index = 1,
Size = 1000,
Sort=" lot_id asc",
Select = "*",
Condition = condition
}) as List;
}
//设置查询条件
date_begin = date_begin.AddDays(-1);
string condition = string.Format("where setDate between '{0}' and '{1}'", date_begin, date_end);
if (this.Lot_platform > -1) condition += " and lot_platform=" + this.Lot_platform;
if (this.Lot_type > -1) condition += " and lot_type=" + this.Lot_type;
//condition += " and lot_id<5375";
//获取数据
return List(new DataObject.Param.Page(){
Count = 1,
Index = 1,
Size = 1000,
Sort=" lot_id asc",
Select = "*",
Condition = condition
}) as List;
}
列表信息——返回数据集示例@使用查询脚本
示例
string sql = "select * from lottery where lot_title like '%'+@lot_title+'%'";
DataSet ds = new LotteryModel().List(new SqlParameter[] {
new SqlParameter("@lot_title", SqlDbType.NVarChar, 20) { Value = "140823" }
}, sql, "Orders", CommandType.Text);
DataSet ds = new LotteryModel().List(new SqlParameter[] {
new SqlParameter("@lot_title", SqlDbType.NVarChar, 20) { Value = "140823" }
}, sql, "Orders", CommandType.Text);
列表信息——返回数据集示例@使用存储过程
示例
"key"搜索关键字 "date_sta"开始时间< "date_end"结束时间 "pageSize"页大小"pageIndex"页索引"count"总数
public ListSearch_Withdraw(string key, string date_sta, string date_end, int shop_id, int pageSize, int pageIndex, int count)
{
DataSet ds = List(new SqlParameter[] {
new SqlParameter("@date_sta", SqlDbType.VarChar, 20) { Value = date_sta },
new SqlParameter("@date_end", SqlDbType.VarChar, 20) { Value = date_end },
new SqlParameter("@key", SqlDbType.NVarChar, 20) { Value = key },
new SqlParameter("@shop_id",SqlDbType.Int,4){Value=shop_id}
}, "rc_Orders_Search_Withdraw", "Orders", pageSize, pageIndex, count);
return ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0 ? new List() : List(ds.Tables[0]) as List;
}
public ListSearch_Withdraw(string key, string date_sta, string date_end, int shop_id, int pageSize, int pageIndex, int count)
{
DataSet ds = List(new SqlParameter[] {
new SqlParameter("@date_sta", SqlDbType.VarChar, 20) { Value = date_sta },
new SqlParameter("@date_end", SqlDbType.VarChar, 20) { Value = date_end },
new SqlParameter("@key", SqlDbType.NVarChar, 20) { Value = key },
new SqlParameter("@shop_id",SqlDbType.Int,4){Value=shop_id}
}, "rc_Orders_Search_Withdraw", "Orders", pageSize, pageIndex, count);
return ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0 ? new List() : List(ds.Tables[0]) as List;
}