Files
QYZH.InteractiveMagazine/QYZH.InteractiveMagazine.IService/IBaseService.cs

40 lines
1.5 KiB
C#
Raw Normal View History

using System.Linq.Expressions;
2026-06-01 13:42:40 +08:00
namespace QYZH.InteractiveMagazine.IService;
/// <summary>
/// 基础服务定义
2026-06-01 13:42:40 +08:00
/// </summary>
/// <typeparam name="T"></typeparam>
2026-06-01 13:42:40 +08:00
public interface IBaseService<T> where T : class, new()
{
Task<T> GetFirstAsync(Expression<Func<T, bool>> whereExpression);
2026-06-01 13:42:40 +08:00
/// <summary>
/// 根据条件表达式查询单条数据
2026-06-01 13:42:40 +08:00
/// </summary>
/// <param name="expression">表达式</param>
/// <returns>泛型实体</returns>
Task<R> GetByIdAsync<R>(Expression<Func<T, bool>> expression) where R : class;
2026-06-01 13:42:40 +08:00
Task<R> GetByExpressionAsync<R>(Expression<Func<T, bool>> expression) where R : class;
2026-06-01 13:42:40 +08:00
Task<List<T2>> GetListByExpression<T2>(Expression<Func<T, bool>> expression) where T2 : class;
2026-06-01 13:42:40 +08:00
Task<bool> UpdateAsync(T updateObj);
2026-06-01 13:42:40 +08:00
///// <summary>
///// 根据指定条件更新指定列 egUpdate(new SysUser(){ Status = 1 }, it => new { it.Status }, f => f.Userid == 1));
///// 只更新Status列条件是包含
///// </summary>
///// <param name="entity">实体类</param>
///// <param name="expression">要更新列的表达式</param>
///// <param name="where">where表达式</param>
///// <returns></returns>
//Task<bool> UpdateAsync(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
Task<bool> UpdateAsync(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression);
Task<bool> UpdateAsync(Expression<Func<T, bool>> columns, Expression<Func<T, bool>> where);
2026-06-01 13:42:40 +08:00
}