41 lines
3.4 KiB
C#
41 lines
3.4 KiB
C#
|
|
using MySqlConnector;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Linq.Expressions;
|
|||
|
|
|
|||
|
|
namespace Cowain.Base.IServices
|
|||
|
|
{
|
|||
|
|
public interface IBaseService
|
|||
|
|
{
|
|||
|
|
int Delete<T>(int Id) where T : class;
|
|||
|
|
int Delete<T>(T t) where T : class;
|
|||
|
|
Task<int> DeleteAsync<T>(int Id, CancellationToken cancellationToken = default) where T : class;
|
|||
|
|
Task<int> DeleteAsync<T>(T t, CancellationToken cancellationToken = default) where T : class;
|
|||
|
|
int ExecuteByDapper(string sql, object? param = null);
|
|||
|
|
Task<int> ExecuteByDapperAsync(string sql, object? param = null, CancellationToken cancellationToken = default);
|
|||
|
|
List<T> Find<T>() where T : class;
|
|||
|
|
T? Find<T>(int id) where T : class;
|
|||
|
|
Task<List<T>> FindAsync<T>(CancellationToken cancellationToken = default) where T : class;
|
|||
|
|
Task<T?> FindAsync<T>(int id, CancellationToken cancellationToken = default) where T : class;
|
|||
|
|
Task<T?> FirstOrDefaultAsync<T>(Expression<Func<T, bool>> funcWhere, CancellationToken cancellationToken = default) where T : class;
|
|||
|
|
DataTable GetDataTable(string sql, IEnumerable<MySqlParameter>? parameters = null);
|
|||
|
|
Task<DataTable> GetDataTableAsync(string sql, IEnumerable<MySqlParameter>? parameters = null, CancellationToken cancellationToken = default);
|
|||
|
|
int Insert<T>(IEnumerable<T> tList) where T : class;
|
|||
|
|
int Insert<T>(T t) where T : class;
|
|||
|
|
Task<int> InsertAsync<T>(IEnumerable<T> tList, CancellationToken cancellationToken = default) where T : class;
|
|||
|
|
Task<int> InsertAsync<T>(T t, CancellationToken cancellationToken = default) where T : class;
|
|||
|
|
List<T> Query<T>(Expression<Func<T, bool>>? funcWhere = null) where T : class;
|
|||
|
|
Task<(List<TViewModel> Data, int TotalCount)> QueryAsync<T, TKey, TViewModel>(Expression<Func<T, TViewModel>> selectExpression, Expression<Func<T, bool>>? funcWhere = null, Expression<Func<T, TKey>>? orderBy = null, bool isAscending = true, int pageIndex = 1, int pageSize = 20, CancellationToken cancellationToken = default) where T : class;
|
|||
|
|
Task<(List<T> Data, int TotalCount)> QueryAsync<T, TKey>(Expression<Func<T, bool>>? funcWhere = null, Expression<Func<T, TKey>>? orderBy = null, bool isAscending = true, int pageIndex = 1, int pageSize = 20, CancellationToken cancellationToken = default) where T : class;
|
|||
|
|
Task<List<T>> QueryAsync<T>(Expression<Func<T, bool>>? funcWhere = null, CancellationToken cancellationToken = default) where T : class;
|
|||
|
|
IEnumerable<T> QueryByDapper<T>(string sql, object? param = null);
|
|||
|
|
Task<IEnumerable<T>> QueryByDapperAsync<T>(string sql, object? param = null, CancellationToken cancellationToken = default);
|
|||
|
|
T? QueryFirstOrDefaultByDapper<T>(string sql, object? param = null);
|
|||
|
|
Task<T?> QueryFirstOrDefaultByDapperAsync<T>(string sql, object? param = null, CancellationToken cancellationToken = default);
|
|||
|
|
DataTable QueryToDataTableByDapper(string sql, object? param = null);
|
|||
|
|
Task<DataTable> QueryToDataTableByDapperAsync(string sql, object? param = null, CancellationToken cancellationToken = default);
|
|||
|
|
int Update<T>(IEnumerable<T> tList) where T : class;
|
|||
|
|
int Update<T>(T t) where T : class;
|
|||
|
|
Task<int> UpdateAsync<T>(IEnumerable<T> tList, CancellationToken cancellationToken = default) where T : class;
|
|||
|
|
Task<int> UpdateAsync<T>(T t, CancellationToken cancellationToken = default) where T : class;
|
|||
|
|
}
|
|||
|
|
}
|