Example #1
0
 public virtual Task <T> ExecuteAsync <T>(IDbAction <T> command, CancellationToken token)
 {
     using (var connection = new SqliteConnection(_connectionString))
     {
         return(command.ExecuteAsync(connection, token));
     }
 }
Example #2
0
 public virtual T Execute <T>(IDbAction <T> command)
 {
     using (var connection = new SqliteConnection(_connectionString))
     {
         return(command.Execute(connection));
     }
 }
Example #3
0
 public static void ToEntry(ActionModel actionModel, IDbAction actionEntry)
 {
     actionEntry.Id                      = actionModel.Id;
     actionEntry.Description             = actionModel.Description;
     actionEntry.Name                    = actionModel.Name;
     actionEntry.Presentation.Visibility = actionModel.Visibility;
     actionEntry.Presentation.Color      = ColorToHex(actionModel.Color);
 }
Example #4
0
        public void Add_WhenHaveNoEmail()
        {
            IDbAction sut = GetInMemoryDbRepository();

            Assert.Equal(1, sut.GetFlats(0, 10).First().Id);
            var flat = sut.GetFlatById(1);

            Assert.NotNull(flat);
            Assert.Equal(3500000m, flat.Price);
            Assert.Equal(2, sut.GetFlats(0, 10).Count());
        }
        public static int Save(this IDbAction action, SqlConnection connection, SqlTransaction transaction = null)
        {
            var D       = action.Insert;
            var command = new SqlCommand(D.Key, connection);

            if (transaction != null)
            {
                command.Transaction = transaction;
            }

            command.Parameters.AddRange(D.Value);
            return(command.ExecuteNonQuery());
        }
        public static int Save(this IDbAction action, string connectionString)
        {
            int result = 0;

            var D = action.Insert;

            using (var connection = new SqlConnection(connectionString))
            {
                connection.Open();
                var command = new SqlCommand(D.Key, connection);

                command.Parameters.AddRange(D.Value);
                result = command.ExecuteNonQuery();
                connection.Close();
            }
            return(result);
        }
Example #7
0
        // 組合 DBAction 的總清單

        private DbActionResource(DBObject.DataBase dataBase, IDbAction dbAction)
        {
            DataBase = dataBase;
            DbAction = dbAction;
        }
Example #8
0
 public HomeController(IDbAction db)
 {
     dbAction = db;
 }