mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 10:37:55 +08:00
同步OpenAuth.Core最新代码
This commit is contained in:
@@ -15,29 +15,30 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenAuth.Repository.Interface
|
||||
{
|
||||
public interface IRepository<T> where T : class
|
||||
{
|
||||
T FindSingle(Expression<Func<T, bool>> exp = null);
|
||||
bool IsExist(Expression<Func<T, bool>> exp);
|
||||
/// <summary>
|
||||
/// 返回一个单独的实体,如果记录多于1个则取第一个
|
||||
/// </summary>
|
||||
T FirstOrDefault(Expression<Func<T, bool>> exp = null);
|
||||
/// <summary>
|
||||
/// 判断指定条件的记录是否存在
|
||||
/// </summary>
|
||||
bool Any(Expression<Func<T, bool>> exp);
|
||||
IQueryable<T> Find(Expression<Func<T, bool>> exp = null);
|
||||
|
||||
IQueryable<T> Find(int pageindex = 1, int pagesize = 10, string orderby = "",
|
||||
Expression<Func<T, bool>> exp = null);
|
||||
|
||||
int GetCount(Expression<Func<T, bool>> exp = null);
|
||||
|
||||
int Count(Expression<Func<T, bool>> exp = null);
|
||||
void Add(T entity);
|
||||
|
||||
void BatchAdd(T[] entities);
|
||||
|
||||
/// <summary>
|
||||
/// 更新一个实体的所有属性
|
||||
/// </summary>
|
||||
void Update(T entity);
|
||||
|
||||
void Delete(T entity);
|
||||
|
||||
|
||||
@@ -48,6 +49,7 @@ namespace OpenAuth.Repository.Interface
|
||||
/// <param name="where">更新条件</param>
|
||||
/// <param name="entity">更新后的实体</param>
|
||||
void Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> entity);
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
@@ -55,19 +57,35 @@ namespace OpenAuth.Repository.Interface
|
||||
|
||||
void Save();
|
||||
|
||||
int ExecuteSql(string sql);
|
||||
|
||||
/// <summary>
|
||||
int ExecuteSqlRaw(string sql);
|
||||
|
||||
/// <summary>
|
||||
/// 使用SQL脚本查询
|
||||
/// </summary>
|
||||
/// <typeparam name="T"> T为数据库实体</typeparam>
|
||||
/// <returns></returns>
|
||||
IQueryable<T> FromSql(string sql, params object[] parameters);
|
||||
/// <summary>
|
||||
/// 使用SQL脚本查询
|
||||
/// </summary>
|
||||
/// <typeparam name="T"> T为非数据库实体,需要在DbContext中增加对应的DbQuery</typeparam>
|
||||
/// <returns></returns>
|
||||
|
||||
/// <summary>
|
||||
/// 使用SQL脚本查询
|
||||
/// </summary>
|
||||
/// <typeparam name="T"> T为非数据库实体,需要在DbContext中增加对应的DbQuery</typeparam>
|
||||
/// <returns></returns>
|
||||
IQueryable<T> Query(string sql, params object[] parameters);
|
||||
|
||||
|
||||
#region 异步接口
|
||||
|
||||
Task<int> ExecuteSqlRawAsync(string sql);
|
||||
Task<int> AddAsync(T entity);
|
||||
Task<int> BatchAddAsync(T[] entities);
|
||||
Task<int> UpdateAsync(T entity);
|
||||
Task<int> DeleteAsync(T entity);
|
||||
Task<int> SaveAsync();
|
||||
Task<int> CountAsync(Expression<Func<T, bool>> exp = null);
|
||||
Task<bool> AnyAsync(Expression<Func<T, bool>> exp);
|
||||
Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> exp);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user