// *********************************************************************** // Assembly : OpenAuth.Domain // Author : yubaolee // Created : 10-25-2015 // // Last Modified By : yubaolee // Last Modified On : 10-25-2015 // *********************************************************************** // // Copyright (c) www.cnblogs.com/yubaolee. All rights reserved. // // 仓储接口 // *********************************************************************** using System; using System.Linq; using System.Linq.Expressions; namespace OpenAuth.Repository.Interface { public interface IRepository where T : class { T FindSingle(Expression> exp = null); bool IsExist(Expression> exp); IQueryable Find(Expression> exp = null); IQueryable Find(int pageindex = 1, int pagesize = 10, string orderby = "", Expression> exp = null); int GetCount(Expression> exp = null); void Add(T entity); void BatchAdd(T[] entities); /// /// 更新一个实体的所有属性 /// void Update(T entity); void Delete(T entity); /// /// 实现按需要只更新部分更新 /// 如:Update(u =>u.Id==1,u =>new User{Name="ok"}); /// /// 更新条件 /// 更新后的实体 void Update(Expression> where, Expression> entity); /// /// 批量删除 /// void Delete(Expression> exp); void Save(); int ExecuteSql(string sql); /// /// 使用SQL脚本查询 /// /// T为数据库实体 /// IQueryable FromSql(string sql, params object[] parameters); /// /// 使用SQL脚本查询 /// /// T为非数据库实体,需要在DbContext中增加对应的DbQuery /// IQueryable Query(string sql, params object[] parameters); } }