int] IDENTITY(1,1) NOT NULL,
[ProductId] [int] NULL,
[UserId] [int] NULL,
[OrderCount] [int] NULL,
[OrderDate] [datetime] NULL,
CONSTRAINT [PK_BeeOrder] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
第一步:配置数据库连接,就是web.config,同上面介绍的配置文件;
第二步:建立实体BeeOrder:
using System;
using System.Collections.Generic;
using System.Text;
namespace FastObjectModel
{
public class BeeOrder
{
private int _id;
public int Id
{
get { return _id; }
set { _id = value; }
}
private int _productId;
public int ProductId
{
get { return _productId; }
set { _productId = value; }
}
private int _userId;
public int UserId
{
get { return _userId; }
set { _userId = value; }
}
private int _orderCount;
public int OrderCount
{
get { return _orderCount; }
set { _orderCount = value; }
}
private DateTime _orderDate;
public DateTime OrderDate
{
get { return _orderDate; }
set { _orderDate = value; }
}
}
}
第三步:添加引用FastObject.dll,使用FastObjectBase.
//....
using System.Collections.Generic;
using System.Data.OleDb;
using FastObjectModel;
using FastObject;
public partial class _Default : System.Web.UI.Page
{
public List<BeeOrder> BeeOrders;
public FastObject.FastObjectBase FOB;
public int PageIndex=10000;
public int PageSize=20;
protected void Page_Load(object sender, EventArgs e)
{
DateTime dt1 = DateTime.Now;
if (Request.QueryString["page"] != null) PageIndex = Convert.ToInt32 (Request.QueryString["page"]);
FOB = new FastObject.FastObjectBase();
if (PageIndex < 1) PageIndex = 1;
BeeOrders = FOB.GetModelsByPage<BeeOrder>("where OrderCount>100 order by id desc", PageIndex, PageSize);
if (PageIndex > FOB.pages)
{
PageIndex = FOB.pages;
BeeOrders = FOB.GetModelsByPage<BeeOrder>("where OrderCount>100 order by id desc", PageIndex, PageSize);
|