Example #1
0
        public async Task ReplaceAsync(Blog blog)
        {
            var propertyContainer = SqlHelpers.ParseProperties(blog);
            var sqlPairs = string.Join(", ", propertyContainer.PairedProperties);

            var sql = $"UPDATE [Blog] SET {sqlPairs};";

            using(var connection = new SqlConnection(ConnectionString))
            {
                await connection.ExecuteAsync(sql, blog);
            }
        }
Example #2
0
        public async Task CreateAsync(Blog blog)
        {
            var propertyContainer = SqlHelpers.ParseProperties(blog);
            var sqlFields = string.Join(", ", propertyContainer.EscapedProperties);
            var sqlParameters = string.Join(", ", propertyContainer.ParameterizedProperties);

            var sql = $"INSERT INTO [Blog] ({sqlFields}) VALUES({sqlParameters});";

            using(var connection = new SqlConnection(ConnectionString))
            {
                await connection.ExecuteAsync(sql, blog);
            }
        }
Example #3
0
 public async Task UpdateBlogAsync(Blog blog)
 {
     await m_blogRepository.ReplaceAsync(blog);
 }
Example #4
0
 public BlogViewModel(Blog blog)
 {
     Title = blog.Title;
 }