ASP.NET MVC EF 02 数据库访问层的设计

1、接口(IBaseRepository(仓储))操作数据库(增删改查),代码如下:

    /// <summary>
    /// 基仓储实现的方法
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IBaseRepository<T> where T : class,new()
    {
        //添加
        T AddEntities(T entity);

        //修改
        bool UpdateEntities(T entity);

        //删除
        bool DeleteEntities(T entity);

        //查询
        IQueryable<T> LodeEntities(Func<T, bool> wherelambda);

        //分页
        IQueryable<T> LoadPagerEntities<S>(int pageSize, int pageIndex,
            out int total, Func<T, bool> wherelambda, bool isAsc, Func<T, S> orderByLambda);
    }

 

 

  

  

posted @ 2016-04-03 16:34  大灰_JYH  阅读(292)  评论(0)    收藏  举报