// ***********************************************************************
// Assembly : OpenAuth.Domain
// Author : yubaolee
// Created : 04-29-2016
//
// Last Modified By : yubaolee
// Last Modified On : 04-29-2016
// Contact : Microsoft
// File: IUnitWork.cs
// ***********************************************************************
using System;
using System.Linq;
using System.Linq.Expressions;
namespace OpenAuth.Domain.Interface
{
///
/// 工作单元接口
/// 适合在一下情况使用:
/// 1 在同一事务中进行多表操作
/// 2 需要多表联合查询
/// 因为架构采用的是EF访问数据库,暂时可以不用考虑采用传统Unit Work的注册机制
///
public interface IUnitWork
{
T FindSingle(Expression> exp = null) where T:class;
bool IsExist(Expression> exp) where T:class;
IQueryable Find(Expression> exp = null) where T:class;
IQueryable Find(int pageindex = 1, int pagesize = 10, string orderby = "",
Expression> exp = null) where T:class;
int GetCount(Expression> exp = null) where T:class;
void Add(T entity) where T:class;
void BatchAdd(T[] entities) where T:class;
///
/// 更新一个实体的所有属性
///
void Update(T entity) where T:class;
void Delete(T entity) where T:class;
///
/// 按指定的ID进行批量更新
///
void Update(Expression> identityExp, T entity) where T:class;
///
/// 实现按需要只更新部分更新
/// 如:Update(u =>u.Id==1,u =>new User{Name="ok"}) where T:class;
///
/// 更新条件
/// 更新后的实体
void Update(Expression> where, Expression> entity) where T:class;
///
/// 批量删除
///
void Delete(Expression> exp) where T:class;
void Save();
}
}