using System; using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Linq; using System.Linq.Expressions; using Learun.Util; namespace Learun.DataBase.Repository { public interface IRepository { DbConnection getDbConnection(); IRepository BeginTrans(); void Commit(); void Rollback(); int ExecuteBySql(string strSql); int ExecuteBySql(string strSql, object dbParameter); int ExecuteByProc(string procName); int ExecuteByProc(string procName, object dbParameter); T ExecuteByProc(string procName) where T : class; T ExecuteByProc(string procName, object dbParameter) where T : class; IEnumerable QueryByProc(string procName) where T : class; IEnumerable QueryByProc(string procName, object dbParameter) where T : class; int Insert(T entity) where T : class; /// /// 仓储下的方法。可以动态的根据第一个参数的T,来插入对应的表 /// /// /// /// /// int InsertByNoMap(T entity, string tablename) where T : class; /// /// 仓储下的方法。可以动态的根据第一个参数的T,来插入对应的表 /// /// /// /// /// int InsertByNoMap(List entities, string tablename) where T : class; int Insert(List entity) where T : class; int Delete(T entity) where T : class; int Delete(List entity) where T : class; int Delete(Expression> condition) where T : class, new(); int Update(T entity) where T : class; /// /// 仓储下的方法。可以动态的根据第一个参数的T,来更新对应的表 /// /// /// /// /// int UpdateByNoMap(T entity, string tablename, string pkcolumn) where T : class; /// /// 仓储下的方法。可以动态的根据第一个参数的T,来更新对应的表 /// /// /// /// /// int UpdateByNoMap(List entities, string tablename, string pkcolumn) where T : class; int UpdateEx(T entity) where T : class; int Update(List entity) where T : class; /// /// 仓储下的方法。根据主键值查找某一个实体 /// /// /// /// T FindEntity(object keyValue) where T : class; T FindEntity(Expression> condition) where T : class, new(); /// /// 仓储下的方法。根据sql查找某一个实体 /// /// /// /// new { account = account },类似这样。会替换sql中@account的字眼 /// T FindEntity(string strSql, object dbParameter) where T : class, new(); IQueryable IQueryable() where T : class, new(); IQueryable IQueryable(Expression> condition) where T : class, new(); IEnumerable FindList() where T : class, new(); /// /// 仓储下的方法。根据sql查找集合 /// /// /// /// IEnumerable FindList(string strSql) where T : class; /// /// 仓储下的方法。根据sql查找集合 /// /// /// /// 参数,到时候sql里的@xxx会被xxx替换。new { TemplateFileID = keyValue } /// IEnumerable FindList(string strSql, object dbParameter) where T : class; IEnumerable FindList(Pagination pagination) where T : class, new(); IEnumerable FindList(Expression> condition, Pagination pagination) where T : class, new(); IEnumerable FindList(Expression> condition) where T : class, new(); IEnumerable FindList(string strSql, Pagination pagination) where T : class; /// /// 仓储下的方法。根据sql查找集合。并进行分页 /// /// /// /// /// 分页对象。包括每页多少 排序方式等 /// IEnumerable FindList(string strSql, object dbParameter, Pagination pagination) where T : class; DataTable FindTable(string strSql); DataTable FindTable(string strSql, object dbParameter); DataTable FindTable(string strSql, Pagination pagination); DataTable FindTable(string strSql, object dbParameter, Pagination pagination); object FindObject(string strSql); object FindObject(string strSql, object dbParameter); IEnumerable GetDBTable() where T : class, new(); IEnumerable GetDBTableFields(string tableName) where T : class, new(); } }