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