158 lines
5.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<T>(string procName) where T : class;
T ExecuteByProc<T>(string procName, object dbParameter) where T : class;
IEnumerable<T> QueryByProc<T>(string procName) where T : class;
IEnumerable<T> QueryByProc<T>(string procName, object dbParameter) where T : class;
int Insert<T>(T entity) where T : class;
/// <summary>
/// 仓储下的方法。可以动态的根据第一个参数的T来插入对应的表
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="entity"></param>
/// <param name="tablename"></param>
/// <returns></returns>
int InsertByNoMap<T>(T entity, string tablename) where T : class;
/// <summary>
/// 仓储下的方法。可以动态的根据第一个参数的T来插入对应的表
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="entity"></param>
/// <param name="tablename"></param>
/// <returns></returns>
int InsertByNoMap<T>(List<T> entities, string tablename) where T : class;
int Insert<T>(List<T> entity) where T : class;
int Delete<T>(T entity) where T : class;
int Delete<T>(List<T> entity) where T : class;
int Delete<T>(Expression<Func<T, bool>> condition) where T : class, new();
int Update<T>(T entity) where T : class;
/// <summary>
/// 仓储下的方法。可以动态的根据第一个参数的T来更新对应的表
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="entity"></param>
/// <param name="tablename"></param>
/// <returns></returns>
int UpdateByNoMap<T>(T entity, string tablename, string pkcolumn) where T : class;
/// <summary>
/// 仓储下的方法。可以动态的根据第一个参数的T来更新对应的表
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="entity"></param>
/// <param name="tablename"></param>
/// <returns></returns>
int UpdateByNoMap<T>(List<T> entities, string tablename, string pkcolumn) where T : class;
int UpdateEx<T>(T entity) where T : class;
int Update<T>(List<T> entity) where T : class;
/// <summary>
/// 仓储下的方法。根据主键值查找某一个实体
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="keyValue"></param>
/// <returns></returns>
T FindEntity<T>(object keyValue) where T : class;
T FindEntity<T>(Expression<Func<T, bool>> condition) where T : class, new();
/// <summary>
/// 仓储下的方法。根据sql查找某一个实体
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="strSql"></param>
/// <param name="dbParameter">new { account = account }类似这样。会替换sql中@account的字眼</param>
/// <returns></returns>
T FindEntity<T>(string strSql, object dbParameter) where T : class, new();
IQueryable<T> IQueryable<T>() where T : class, new();
IQueryable<T> IQueryable<T>(Expression<Func<T, bool>> condition) where T : class, new();
IEnumerable<T> FindList<T>() where T : class, new();
/// <summary>
/// 仓储下的方法。根据sql查找集合
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="strSql"></param>
/// <returns></returns>
IEnumerable<T> FindList<T>(string strSql) where T : class;
/// <summary>
/// 仓储下的方法。根据sql查找集合
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="strSql"></param>
/// <param name="dbParameter">参数到时候sql里的@xxx会被xxx替换。new { TemplateFileID = keyValue }</param>
/// <returns></returns>
IEnumerable<T> FindList<T>(string strSql, object dbParameter) where T : class;
IEnumerable<T> FindList<T>(Pagination pagination) where T : class, new();
IEnumerable<T> FindList<T>(Expression<Func<T, bool>> condition, Pagination pagination) where T : class, new();
IEnumerable<T> FindList<T>(Expression<Func<T, bool>> condition) where T : class, new();
IEnumerable<T> FindList<T>(string strSql, Pagination pagination) where T : class;
/// <summary>
/// 仓储下的方法。根据sql查找集合。并进行分页
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="strSql"></param>
/// <param name="dbParameter"></param>
/// <param name="pagination">分页对象。包括每页多少 排序方式等</param>
/// <returns></returns>
IEnumerable<T> FindList<T>(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<T> GetDBTable<T>() where T : class, new();
IEnumerable<T> GetDBTableFields<T>(string tableName) where T : class, new();
}
}