Beispiel #1
0
 /// <summary>
 /// 执行一个删除的命令,在删除命令中 <paramref name="entityOrPKValues"/> 可以是主键的值(表只有一个主键),也可以是匿名对象的部分成员(<paramref name="entityOrPKValues"/> 属性成员和 <typeparamref name="TEntity"/> 属性成员必须一致)。
 /// </summary>
 /// <typeparam name="TEntity">实体的数据类型。</typeparam>
 /// <param name="engine">数据源查询与交互引擎的实例。</param>
 /// <param name="entityOrPKValues">实体的实例对象,在删除命令中 <paramref name="entityOrPKValues"/> 可以是主键的值(表只有一个主键,值允许是一个数组,表示删除多条记录),也可以是匿名对象的部分成员(<paramref name="entityOrPKValues"/> 属性成员和 <typeparamref name="TEntity"/> 属性成员必须一致)。</param>
 /// <param name="tableName">实体的实际表名称,可以为 null 值。</param>
 /// <returns>返回一个查询结果。</returns>
 public static DbResult <int> RemoveAnonymous <TEntity>(this IDbEngine engine, object entityOrPKValues, string tableName = null)
 {
     if (engine == null)
     {
         throw new ArgumentNullException("engine");
     }
     if (entityOrPKValues == null)
     {
         throw new ArgumentNullException("entityOrPKValues");
     }
     return(engine.ExecuteAED <TEntity>(mapper => engine.Owner.Injector.CreateDeleteCommand(engine, mapper, entityOrPKValues, tableName)));
 }
Beispiel #2
0
 /// <summary>
 /// 执行一个更新的命令,可以是匿名对象的部分成员(<paramref name="entity"/> 属性成员和 <typeparamref name="TEntity"/> 属性成员必须一致)。
 /// </summary>
 /// <typeparam name="TEntity">实体的数据类型。</typeparam>
 /// <param name="engine">数据源查询与交互引擎的实例。</param>
 /// <param name="entity">实体的实例对象,可以是匿名对象的部分成员(<paramref name="entity"/> 属性成员和 <typeparamref name="TEntity"/> 属性成员必须一致)。</param>
 /// <param name="tableName">实体的实际表名称,可以为 null 值。</param>
 /// <returns>返回一个查询结果。</returns>
 public static DbResult <int> ModifyAnonymous <TEntity>(this IDbEngine engine, object entity, string tableName = null)
 {
     if (engine == null)
     {
         throw new ArgumentNullException("engine");
     }
     if (entity == null)
     {
         throw new ArgumentNullException("entity");
     }
     return(engine.ExecuteAED <TEntity>(mapper => engine.Owner.Injector.CreateUpdateCommand(engine, mapper, entity, tableName)));
 }