Tüm Ürünler
Search
Belge Merkezi

Tablestore:Write a single row

Son Güncelleme:Oct 02, 2026

.NET SDK kullanarak Tablestore tablosuna tek bir veri satırı yazın.

Önkoşullar

Tablestore istemcisini başlatma

Yöntem

public PutRowResponse PutRow(PutRowRequest request)

Eşzamansız yöntem:

public Task<PutRowResponse> PutRowAsync(PutRowRequest request)

PutRowRequest parametreleri

Parametre

Tür

Açıklama

tableName (Gerekli)

string

Tablo adı.

primaryKey (Gerekli)

PrimaryKey

Satır için birincil anahtar sütun adları ve değerleri.

  • Birincil anahtar sütunları için geçerli veri türleri STRING, INTEGER ve BINARY'dir.

  • Birincil anahtar sütunlarının sayısı ve veri türleri tablonun şemasıyla eşleşmelidir.

columns (İsteğe bağlı)

AttributeColumns

Adlar, değerler ve veri sürümleri dahil olmak üzere öznitelik sütunları.

  • Öznitelik sütunları için geçerli veri türleri STRING, INTEGER, BINARY, DOUBLE ve BOOLEAN'dir.

  • Tablestore bir veri sürümünü otomatik olarak oluşturur. Özel bir sürüm de belirtebilirsiniz. Daha fazla bilgi için bkz. Veri sürümü ve yaşam süresi.

condition (Gerekli)

Condition

Yazma işlemi için koşul. Daha fazla bilgi için bkz. koşullu yazmalar.

Örnek kod

Aşağıdaki örnek, "test_table" tablosuna birincil anahtar değeri "row1" olan bir satır yazar.

try
{
    // Construct the primary key.
    PrimaryKey primaryKey = new PrimaryKey
    {
        { "id", new ColumnValue("row1") }
    };
    // Specify a condition for the write operation. 
    // RowExistenceExpectation.IGNORE skips the row existence check.
    Condition condition = new Condition(RowExistenceExpectation.IGNORE);

    // Call the PutRow method to write the row.
    PutRowRequest putRowRequest = new PutRowRequest("test_table", condition, primaryKey, null);
    PutRowResponse putRowResponse = client.PutRow(putRowRequest);
    Console.WriteLine($"* RequestId: {putRowResponse.RequestID}");
    Console.WriteLine($"* Read CU Cost: {putRowResponse.ConsumedCapacityUnit.Read}");
    Console.WriteLine($"* Write CU Cost: {putRowResponse.ConsumedCapacityUnit.Write}");
}
catch (Exception ex)
{
    Console.WriteLine($"Put row failed, exception: {ex.Message}");
}
  • Öznitelik sütunları ekleyin.

    AttributeColumns columns = new AttributeColumns
    {
        { "col1", new ColumnValue("val1") }
    };
    
    // Create a PutRowRequest.
    PutRowRequest putRowRequest = new PutRowRequest("test_table", condition, primaryKey, columns);

İlgili konular

Toplu iş olarak veri yazma