[C#] 纯文本查看 复制代码 Hr_EmployeeBLL hr_el = new Hr_EmployeeBLL();
//------------------------------------------------------查询------------------------------------------------------------------------
//查询所有
List<Hr_Employee> list = hr_el.FindList();
//根据条件查询
list = hr_el.FindList("UserID=232");
//根据条件查询 支持直接自己写SQl语句
list = hr_el.FindList("select top 5 * from Hr_Employee where UserID<>@UserID", DictBuilder.Assign("UserID", 109));
//根据条件查询 参数必须出现在语句中
list = hr_el.FindList("UserID=@UserID and Password=@Password", DictBuilder.Assign("UserID", 233).Assign("Password", 12345));
//根据条件查询 自动组织参数
list = hr_el.FindListWhere(DictBuilder.Assign("Password", "12345").IN("UserID", new int[] { 233, 1180, 326, 325 }));
long totalcount = 0;
//根据条件查询-分页
list = hr_el.FindListPage(
new OrmLitePageFactor()
{
Conditions = "UserID<>@UserID",
OrderBy = "UserID desc",
PageIndex = 2,
PageSize = 20,
Params = DictBuilder.Assign("UserID", 109)
},
out totalcount);
//------------------------------------------------------写入------------------------------------------------------------------------
Hr_Employee obj = new Hr_Employee()
{
Birthday = string.Empty,
BranchID = 1,
CheckinDate = DateTime.Now,
UserName = "sufei"
};
//long userid = hr_el.Insert(obj, true);
//------------------------------------------------------修改------------------------------------------------------------------------
int result = 0;
obj = new Hr_Employee()
{
Birthday = string.Empty,
CheckinDate = DateTime.Now,
UserName = "sufei"
};
//result = hr_el.Update(obj, new string[] { "Birthday", "UserName", "CheckinDate" });
//条件修改
result = hr_el.Update(
DictBuilder.Assign("UserName", "sufei"), "UserName=@UserName1",
DictBuilder.Assign("UserName1", "sufei"));
//------------------------------------------------------删除------------------------------------------------------------------------
//result = hr_el.Delete("UserName=@UserName", DictBuilder.Assign("UserName", "sufei"));
//------------------------------------------------------其他------------------------------------------------------------------------
long countall = hr_el.Count();//总行
long count = hr_el.Count("UserID<>@UserID", DictBuilder.Assign("UserID", 1516));//sql查询
count = hr_el.Count("UserID<>1516");//单SQl查询
|