/// <summary>
        /// Executes the <see cref="SqlText"/>.
        /// </summary>
        /// <param name="sqlExecute"></param>
        /// <param name="sqlText"></param>
        /// <returns></returns>
        public static int Execute(this ISqlExecute sqlExecute, SqlText sqlText)
        {
            string sql = sqlText.Sql();

            if (string.IsNullOrEmpty(sql))
            {
                return(0);
            }

            return(sqlExecute.Execute(sql, sqlText.Parameters, CommandType.Text));
        }
Exemplo n.º 2
0
        public void Execute_excutes_with_arguments()
        {
            ISqlExecute         sqlExecute = A.Fake <ISqlExecute>();
            SqlText             sqlText    = A.Fake <SqlText>();
            ParameterCollection parameters = new ParameterCollection();
            const string        sql        = "select 1";

            A.CallTo(() => sqlText.Sql()).Returns(sql);
            A.CallTo(() => sqlText.Parameters).Returns(parameters);

            sqlExecute.Execute(sqlText);

            A.CallTo(() => sqlExecute.Execute(sql, parameters, CommandType.Text, null)).MustHaveHappenedOnceExactly();
        }
Exemplo n.º 3
0
 public SqlExecutions(ISqlExecute <TEntity> add, ISqlExecute <TEntity> delete, ISqlExecute <TEntity> update, ISqlExecute <TEntity> unmodified)
 {
     //if (add == null)
     //    throw new ArgumentNullException(nameof(add));
     //if (delete == null)
     //    throw new ArgumentNullException(nameof(delete));
     //if (update == null)
     //    throw new ArgumentNullException(nameof(update));
     //if (unmodified == null)
     //    throw new ArgumentNullException(nameof(unmodified));
     Add        = add;
     Delete     = delete;
     Update     = update;
     Unmodified = unmodified;
 }
Exemplo n.º 4
0
 public BaseTrackeable(TEntity entity, ISqlExecute <TEntity> sqlExecute)
 {
     SqlExecute = sqlExecute;
     Current    = entity;
 }
Exemplo n.º 5
0
 public static void Begin(TestContext testContext)
 {
     sqlExecute = StartServiceTests.Container.Resolve <ISqlExecute>();
 }
 public DeletedTrackeable(TEntity entity, ISqlExecute <TEntity> sqlExecute) : base(entity, sqlExecute)
 {
 }
 public UnmodifiedTrackeable(TEntity entity, ISqlExecute <TEntity> sqlExecute) : base(entity, sqlExecute)
 {
 }
Exemplo n.º 8
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="sqlExecute"></param>
 public DbContext(ISqlExecute sqlExecute)
 {
     this.sqlExecute = sqlExecute;
 }
Exemplo n.º 9
0
 /// <summary>
 /// 关闭数据库上下文
 /// </summary>
 public void Dispose()
 {
     sqlExecute.Close();
     sqlExecute = null;
 }