mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
add admin
This commit is contained in:
@ -1,42 +1,89 @@
|
||||
//using FreeSql.Site.Entity;
|
||||
using FreeSql.Site.Entity;
|
||||
using FreeSql.Site.Entity;
|
||||
using FreeSql.Site.Entity.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
|
||||
namespace FreeSql.Site.DAL
|
||||
{
|
||||
public class DocumentContentDAL
|
||||
{
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public long Insert(DocumentContent model)
|
||||
{
|
||||
return Db.mysql.Insert<DocumentContent>(model).ExecuteIdentity();
|
||||
return DataBaseType.MySql.DB().Insert<DocumentContent>(model).ExecuteIdentity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public bool Update(DocumentContent model)
|
||||
{
|
||||
return Db.mysql.Update<DocumentContent>(model.ID).ExecuteUpdated().Count > 0;
|
||||
return DataBaseType.MySql.DB().Update<DocumentContent>(model.ID).ExecuteUpdated().Count > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public bool Delete(long id)
|
||||
{
|
||||
return Db.mysql.Delete<DocumentContent>(id).ExecuteDeleted().Count > 0;
|
||||
return DataBaseType.MySql.DB().Delete<DocumentContent>(id).ExecuteDeleted().Count > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取一条数据
|
||||
/// </summary>
|
||||
/// <param name="where"></param>
|
||||
/// <returns></returns>
|
||||
public DocumentContent GetByOne(Expression<Func<DocumentContent, bool>> where)
|
||||
{
|
||||
return Db.mysql.Select<DocumentContent>()
|
||||
return DataBaseType.MySql.DB().Select<DocumentContent>()
|
||||
.Where(where).ToOne();
|
||||
}
|
||||
|
||||
public List<DocumentContent> Query(Expression<Func<DocumentContent, bool>> where,
|
||||
Expression<Func<DocumentContent, DocumentContent>> orderby = null)
|
||||
|
||||
/// <summary>
|
||||
/// 获取一条数据
|
||||
/// </summary>
|
||||
/// <param name="where"></param>
|
||||
/// <returns></returns>
|
||||
public long Count(Expression<Func<DocumentContent, bool>> where)
|
||||
{
|
||||
var list = Db.mysql.Select<DocumentContent>()
|
||||
return DataBaseType.MySql.DB().Select<DocumentContent>()
|
||||
.Where(where).Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询功能
|
||||
/// </summary>
|
||||
/// <param name="where"></param>
|
||||
/// <param name="orderby"></param>
|
||||
/// <returns></returns>
|
||||
public (List<DocumentContent> list, long count) Query(Expression<Func<DocumentContent, bool>> where,
|
||||
Expression<Func<DocumentContent, DocumentContent>> orderby = null, PageInfo pageInfo = null)
|
||||
{
|
||||
//设置查询条件
|
||||
var list = DataBaseType.MySql.DB().Select<DocumentContent>()
|
||||
.Where(where);
|
||||
|
||||
//设置排序
|
||||
if (orderby != null) list = list.OrderBy(b => b.CreateDt);
|
||||
return list.ToList();
|
||||
|
||||
var count = list.Count();
|
||||
//设置分页操作
|
||||
if (pageInfo != null && pageInfo.IsPaging)
|
||||
list.Skip(pageInfo.PageIndex * pageInfo.PageSize).Limit(pageInfo.PageSize);
|
||||
|
||||
//执行查询
|
||||
return (list.ToList(), count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user