using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CM.Api.Utility
{
public class ResponseJson
{
public string Code { get; set; }
public string Msg { get; set; }
public int Count { get; set; }
public object Data { get; set; }
public ResponseJson()
{
Code = "200";
Msg = "ok";
Count = 0;
}
}
}
CM.Repository 主要用於數據庫操作,在該目錄下定義接口 IRepository.cs
IRepository.cs代碼:
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
namespace CM.Repository
{
public interface IRepository<T> where T : class, new()
{
#region
// 獲取模型對象
T GetModel(dynamic id);
T GetModel(Expression<Func<T, bool>> expression);
// 獲取所有
List<T> GetList();
List<T> GetList(string where);
List<T> GetList(Expression<Func<T, bool>> expression);
// 獲取分頁列表
List<T> GetPageList(int pageIndex, int pageSize);
List<T> GetPageList(int pageIndex, int pageSize, string where);
List<T> GetPageList(int pageIndex, int pageSize, Expression<Func<T, bool>> expression);
// 增加
bool Insert(T obj);
// 根據主鍵刪除
bool Delete(dynamic id);
bool Delete(Expression<Func<T, bool>> expression);
// 根據主鍵批量刪除
bool DeleteList(List<dynamic> ids);
bool DeleteList(string ids);
// 更新
bool Update(T obj);
// 判斷主鍵是否存在
bool Exists(dynamic id);
#endregion
}
}