Exemple #1
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <typeparam name="TEntity">实体类型</typeparam>
 /// <param name="entity">实体</param>
 /// <param name="where">条件表达式 Get(p => p.ID == 100 &amp;&amp; p.Name == "hhahh2011") 或者使用Spec</param>
 /// <param name="select">选择列表达式 Get(p => new Columns(p.ID, p.Name))</param>
 /// <param name="trans">事务</param>
 /// <returns>受影响的行数</returns>
 protected virtual int DMUpdate <TEntity>(TEntity entity, Expression <Func <TEntity, bool> > where, Expression <Func <TEntity, Columns> > select, IDbTransaction trans)
 {
     return(DMContext.Update <TEntity>(entity, where, select, trans));
 }
Exemple #2
0
 public virtual int Save <TEntity>(TEntity entity, Expression <Func <TEntity, bool> > where, Expression <Func <TEntity, Columns> > select, string connectionString)
 {
     return(DMContext.Update <TEntity>(entity, where, select, null, connectionString));
 }
Exemple #3
0
 public static TService GetService <TService>() where TService : class
 {
     return(DMContext.GetService <TService>());
 }
Exemple #4
0
 public virtual int Remove <TEntity>(Expression <Func <TEntity, bool> > where)
 {
     return(DMContext.Delete <TEntity>(where));
 }
Exemple #5
0
 public virtual int Remove <TEntity>(Expression <Func <TEntity, bool> > where, string connectionString)
 {
     return(DMContext.Delete <TEntity>(where, null, connectionString));
 }
Exemple #6
0
 public virtual TEntity Get <TEntity>(Expression <Func <TEntity, bool> > where, Expression <Func <TEntity, Columns> > select = null, string connectionString = null)
 {
     return(DMContext.Query <TEntity>().Where(where).Select(select).SetConnectionString(connectionString).Single());
 }
Exemple #7
0
 public virtual List <TEntity> GetList <TEntity>(int top, Expression <Func <TEntity, bool> > where = null, Expression <Func <TEntity, Columns> > order = null, Expression <Func <TEntity, Columns> > select = null, string connectionString = null)
 {
     return(DMContext.Query <TEntity>().Where(where).OrderBy(order).Select(select).SetConnectionString(connectionString).ToList(top));
 }
Exemple #8
0
 public int Remove <T>(Expression <Func <T, bool> > where)
 {
     return(DMContext.Delete(where, this.trans.BeginTransaction()));
 }
Exemple #9
0
 public int Save <T>(T t, Expression <Func <T, bool> > where, Expression <Func <T, Columns> > select = null)
 {
     return(DMContext.Update(t, where, select, this.trans.BeginTransaction()));
 }
Exemple #10
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <typeparam name="TEntity">实体类型</typeparam>
 /// <param name="entity">实体</param>
 /// <param name="select">要插入的列 Add(p => new Columns(p.ID, p.Name)) 不填则为插入所有字段 除主键外</param>
 /// <returns>如果主键是自增长的话,返回自增长的id 同时item里面的主键也被设置为id</returns>
 protected virtual int DMInsert <TEntity>(TEntity entity, Expression <Func <TEntity, Columns> > select)
 {
     return(DMContext.Insert <TEntity>(entity, select));
 }
Exemple #11
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <typeparam name="TEntity">实体类型</typeparam>
 /// <param name="entity">实体</param>
 /// <param name="select">要插入的列 Add(p => new Columns(p.ID, p.Name)) 不填则为插入所有字段 除主键外</param>
 /// <param name="connectionString">自定义数据库连接</param>
 /// <returns>如果主键是自增长的话,返回自增长的id 同时item里面的主键也被设置为id</returns>
 protected virtual int DMInsert <TEntity>(TEntity entity, Expression <Func <TEntity, Columns> > select, string connectionString)
 {
     return(DMContext.Insert <TEntity>(entity, select, null, connectionString));
 }
Exemple #12
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <typeparam name="TEntity">实体类型</typeparam>
 /// <param name="entity">实体</param>
 /// <param name="trans">事务</param>
 /// <returns>如果主键是自增长的话,返回自增长的id 同时item里面的主键也被设置为id</returns>
 protected virtual int DMInsert <TEntity>(TEntity entity, IDbTransaction trans)
 {
     return(DMContext.Insert <TEntity>(entity, null, trans));
 }
Exemple #13
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <typeparam name="TEntity">实体类型</typeparam>
 /// <param name="entity">实体</param>
 /// <param name="where">条件表达式 Get(p => p.ID == 100 &amp;&amp; p.Name == "hhahh2011") 或者使用Spec</param>
 /// <returns>受影响的行数</returns>
 protected virtual int DMUpdate <TEntity>(TEntity entity, Expression <Func <TEntity, bool> > where)
 {
     return(DMContext.Update <TEntity>(entity, where));
 }
Exemple #14
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <typeparam name="TEntity">实体类型</typeparam>
 /// <param name="entity">实体</param>
 /// <param name="where">条件表达式 Get(p => p.ID == 100 &amp;&amp; p.Name == "hhahh2011") 或者使用Spec</param>
 /// <param name="connectionString">自定义连接</param>
 /// <returns>受影响的行数</returns>
 protected virtual int DMUpdate <TEntity>(TEntity entity, Expression <Func <TEntity, bool> > where, string connectionString)
 {
     return(DMContext.Update <TEntity>(entity, where, null, null, connectionString));
 }
Exemple #15
0
 public virtual int Add <TEntity>(TEntity t, Expression <Func <TEntity, Columns> > select, string connectionString)
 {
     return(DMContext.Insert <TEntity>(t, select, null, connectionString));
 }
Exemple #16
0
 public int Add <T>(T t, Expression <Func <T, Columns> > select = null)
 {
     return(DMContext.Insert(t, select, this.trans.BeginTransaction()));
 }
Exemple #17
0
 public virtual int Add <TEntity>(TEntity t)
 {
     return(DMContext.Insert <TEntity>(t));
 }
Exemple #18
0
 public virtual ATSqlCommand GetTSqlCommand(string cmdText, IList <IDbDataParameter> parameter = null, IDbTransaction trans = null)
 {
     return(DMContext.TSqlCommand(cmdText, parameter, trans));
 }
Exemple #19
0
 public virtual List <TEntity> GetAll <TEntity>(Expression <Func <TEntity, Columns> > order = null, Expression <Func <TEntity, Columns> > select = null, string connectionString = null)
 {
     return(DMContext.Query <TEntity>().OrderBy(order).Select(select).SetConnectionString(connectionString).ToList());
 }
Exemple #20
0
 public virtual int Save <TEntity>(TEntity entity, Expression <Func <TEntity, bool> > where)
 {
     return(DMContext.Update <TEntity>(entity, where));
 }
Exemple #21
0
 public virtual PageList <TEntity> GetPageList <TEntity>(int pageIndex, int pageSize, Expression <Func <TEntity, bool> > where = null, Expression <Func <TEntity, Columns> > order = null, Expression <Func <TEntity, Columns> > select = null, string connectionString = null)
 {
     return(DMContext.Query <TEntity>().Where(where).OrderBy(order).Select(select).SetConnectionString(connectionString).ToPageList(pageIndex, pageSize));
 }
Exemple #22
0
 public virtual int Add <TEntity>(TEntity entity, IDbTransaction trans)
 {
     return(DMContext.Insert <TEntity>(entity, null, trans));
 }
Exemple #23
0
 public virtual int Remove <TEntity>(Expression <Func <TEntity, bool> > where, IDbTransaction trans)
 {
     return(DMContext.Delete <TEntity>(where, trans));
 }
Exemple #24
0
 public virtual int Add <TEntity>(TEntity entity, string connectionString)
 {
     return(DMContext.Insert <TEntity>(entity, null, null, connectionString));
 }
Exemple #25
0
 public virtual int Save <TEntity>(TEntity entity, Expression <Func <TEntity, bool> > where, IDbTransaction trans)
 {
     return(DMContext.Update <TEntity>(entity, where, null, trans));
 }
Exemple #26
0
 public virtual int Add <TEntity>(TEntity t, Expression <Func <TEntity, Columns> > select, IDbTransaction trans)
 {
     return(DMContext.Insert <TEntity>(t, select, trans));
 }
Exemple #27
0
 public virtual int Save <TEntity>(TEntity entity, Expression <Func <TEntity, bool> > where, Expression <Func <TEntity, Columns> > select)
 {
     return(DMContext.Update <TEntity>(entity, where, select));
 }
Exemple #28
0
 public virtual int Add <TEntity>(TEntity t, Expression <Func <TEntity, Columns> > select)
 {
     return(DMContext.Insert <TEntity>(t, select));
 }
Exemple #29
0
 public static void Register <TService, TImpl>()
     where TService : class
     where TImpl : class, TService
 {
     DMContext.Register <TService, TImpl>();
 }
Exemple #30
0
 /// <summary>
 /// 分页获取记录集合
 /// </summary>
 /// <typeparam name="TEntity">实体类型</typeparam>
 /// <param name="pageIndex">第几页</param>
 /// <param name="pageSize">每页大小</param>
 /// <returns>符合条件的记录集合</returns>
 protected virtual PageList <TEntity> DMSelectPageList <TEntity>(int pageIndex, int pageSize)
 {
     return(DMContext.Query <TEntity>().ToPageList(pageIndex, pageSize));
 }