示例#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);
            }
        }
示例#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);
            }
        }
示例#3
0
 public async Task UpdateBlogAsync(Blog blog)
 {
     await m_blogRepository.ReplaceAsync(blog);
 }
示例#4
0
 public BlogViewModel(Blog blog)
 {
     Title = blog.Title;
 }