Tüm Ürünler
Search
Belge Merkezi

Tablestore:Update a single row

Son Güncelleme:Oct 02, 2026

Tablestore .NET SDK'yı kullanarak tek bir satırı güncelleyin. Öznitelik sütunu değerlerini değiştirebilir, sütun ekleyebilir veya belirli sürümleri ya da tüm öznitelik sütunlarını silebilirsiniz.

Ön koşullar

Tablestore istemcisini başlatma

Yöntem

public UpdateRowResponse UpdateRow(UpdateRowRequest request)

Zaman uyumsuz yöntem:

public Task<UpdateRowResponse> UpdateRowAsync(UpdateRowRequest request)

UpdateRowRequest parametreleri

Parametre

Tür

Açıklama

tableName (Gerekli)

string

Tablonun adı.

primaryKey (Gerekli)

PrimaryKey

Sütun adları ve değerleri dahil olmak üzere güncellenecek satırın birincil anahtarı.

  • Desteklenen veri türleri: STRING, INTEGER ve BINARY.

  • Sütun sayısı ve veri türleri, tablonun birincil anahtar şemasıyla eşleşmelidir.

updateOfAttribute (Gerekli)

UpdateOfAttribute

Güncellenecek öznitelik sütunları ve güncelleme işlemi türü.

condition (Gerekli)

Condition

Güncelleme koşulu. Koşullu güncelleme.

Örnek kod

Bu örnek, birincil anahtarı row1 olan satırı günceller ve col1 öznitelik sütununun değerini changed_val1 olarak ayarlar.

try
{
    // Construct the primary key.
    PrimaryKey primaryKey = new PrimaryKey
    {
        { "id", new ColumnValue("row1") }
    };
    // Define the attribute columns to update.
    UpdateOfAttribute updateOfAttribute = new UpdateOfAttribute();
    updateOfAttribute.AddAttributeColumnToPut("col1", new ColumnValue("changed_val1"));
    // You must specify a condition when updating a row. (RowExistenceExpectation.IGNORE skips the row existence check.)
    Condition condition = new Condition(RowExistenceExpectation.IGNORE);

    // Call the UpdateRow method to update the row.
    UpdateRowRequest updateRowRequest = new UpdateRowRequest("test_table", condition, primaryKey, updateOfAttribute);
    UpdateRowResponse updateRowResponse = client.UpdateRow(updateRowRequest);
    Console.WriteLine($"RequestId: {updateRowResponse.RequestID}");
    Console.WriteLine($"Read CU Cost: {updateRowResponse.ConsumedCapacityUnit.Read}");
    Console.WriteLine($"Write CU Cost: {updateRowResponse.ConsumedCapacityUnit.Write}");
}
catch (Exception ex)
{
    Console.WriteLine($"Update row failed, exception: {ex.Message}");
}

Aşağıdaki işlemleri de yapabilirsiniz:

  • Bir öznitelik sütunu ekleyin.

    updateOfAttribute.AddAttributeColumnToPut("col2", new ColumnValue("val2"));
  • Tüm bir öznitelik sütununu silin.

    updateOfAttribute.AddAttributeColumnToDelete("col2");

İlgili konular