using InSituLaboratory.Base;
using Microsoft.Data.SqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace InSituLaboratory.IService
{
public interface IBaseService
{
#region Query
///
/// 根据id查询实体
///
///
///
T Find(int id) where T : class;
///
/// 提供对单表的查询
///
/// IQueryable类型集合
[Obsolete("尽量避免使用,using 带表达式目录树的 代替")]
IQueryable Set() where T : class;
///
/// 查询
///
///
///
///
IQueryable Query(Expression> funcWhere) where T : class;
///
/// 分页查询
///
///
///
///
///
///
///
///
///
PageResult QueryPage(Expression> funcWhere, int pageSize, int pageIndex, Expression> funcOrderby, bool isAsc = true) where T : class;
#endregion
#region Add
///
/// 新增数据,即时Commit
///
///
/// 返回带主键的实体
T Insert(T t) where T : class;
///
/// 新增数据,即时Commit
/// 多条sql 一个连接,事务插入
///
///
IEnumerable Insert(IEnumerable tList) where T : class;
#endregion
#region Update
///
/// 更新数据,即时Commit
///
///
void Update(T t) where T : class;
///
/// 更新数据,即时Commit
///
///
void Update(IEnumerable tList) where T : class;
#endregion
#region Delete
///
/// 根据主键删除数据,即时Commit
///
///
void Delete(int Id) where T : class;
///
/// 删除数据,即时Commit
///
///
void Delete(T t) where T : class;
///
/// 删除数据,即时Commit
///
///
void Delete(IEnumerable tList) where T : class;
#endregion
#region Other
///
/// 立即保存全部修改
/// 把增/删的savechange给放到这里,是为了保证事务的
///
void Commit();
///
/// 执行sql 返回集合
///
///
///
///
IQueryable ExcuteQuery(string sql, SqlParameter[] parameters) where T : class;
///
/// 执行sql,无返回
///
///
///
void Excute(string sql, SqlParameter[] parameters) where T : class;
#endregion
}
}