using FreeSql.Site.Entity; using FreeSql.Site.Entity.Common; using System; using System.Collections.Generic; using System.Linq.Expressions; namespace FreeSql.Site.DAL { public class DocumentContentDAL { /// /// 新增 /// /// /// public long Insert(DocumentContent model) { return DataBaseType.MySql.DB().Insert(model).ExecuteIdentity(); } /// /// 修改 /// /// /// public bool Update(DocumentContent model) { return DataBaseType.MySql.DB().Update(model.ID).ExecuteUpdated().Count > 0; } /// /// 删除 /// /// /// public bool Delete(long id) { return DataBaseType.MySql.DB().Delete(id).ExecuteDeleted().Count > 0; } /// /// 获取一条数据 /// /// /// public DocumentContent GetByOne(Expression> where) { return DataBaseType.MySql.DB().Select() .Where(where).ToOne(); } /// /// 获取一条数据 /// /// /// public long Count(Expression> where) { return DataBaseType.MySql.DB().Select() .Where(where).Count(); } /// /// 查询功能 /// /// /// /// public (List list, long count) Query(Expression> where, Expression> orderby = null, PageInfo pageInfo = null) { //设置查询条件 var list = DataBaseType.MySql.DB().Select() .Where(where); //设置排序 if (orderby != null) list = list.OrderBy(b => b.CreateDt); var count = list.Count(); //设置分页操作 if (pageInfo != null && pageInfo.IsPaging) list.Skip(pageInfo.PageIndex * pageInfo.PageSize).Limit(pageInfo.PageSize); //执行查询 return (list.ToList(), count); } } }