RowPutChange ClassAliyun Open Services SDK for .NET
表示行的插入或更新信息。
Inheritance Hierarchy

SystemObject
  Aliyun.OpenServices.OpenTableServiceRowChange
    Aliyun.OpenServices.OpenTableServiceRowPutChange

Namespace: Aliyun.OpenServices.OpenTableService
Assembly: Aliyun.OpenServices (in Aliyun.OpenServices.dll) Version: 1.0.5290.21916
Syntax

public class RowPutChange : RowChange

The RowPutChange type exposes the following members.

Constructors

  NameDescription
Public methodRowPutChange
初始化新的RowPutChange实例。
Public methodRowPutChange(IDictionaryString, PrimaryKeyValue)
初始化新的RowPutChange实例。
Public methodRowPutChange(IDictionaryString, PrimaryKeyValue, IDictionaryString, ColumnValue)
初始化新的RowPutChange实例。
Top
Methods

  NameDescription
Public methodEquals
确定指定的 Object 是否等于当前的 Object
(Inherited from Object.)
Protected methodFinalize
允许 Object 在“垃圾回收”回收 Object 之前尝试释放资源并执行其他清理操作。
(Inherited from Object.)
Public methodGetHashCode
用作特定类型的哈希函数。
(Inherited from Object.)
Public methodGetType
获取当前实例的 Type
(Inherited from Object.)
Protected methodMemberwiseClone
创建当前 Object 的浅表副本。
(Inherited from Object.)
Public methodToString
返回表示当前 ObjectString
(Inherited from Object.)
Top
Properties

  NameDescription
Public propertyAttributeColumns
获取属性列(Attribute Column)名称与值的对应字典。
Public propertyCheckingMode
获取或设置进行数据存在性检查的方式。
Public propertyPrimaryKeys
获取主键(Primary Key)列名称与值的对应字典。
(Inherited from RowChange.)
Top
Examples

下面的示例代码演示如何通过OtsClient的方法插入一条数据。
using System;
using System.Linq;
using Aliyun.OpenServices.OpenTableService;

namespace Aliyun.OpenServices.Samples.OpenTableService
{
    class PutDataSample
    {
        string endpoint = "http://ots.aliyuncs.com";
        string accessId = "<your access id>";
        string accessKey = "<your access key>";

        public void PutData(string tableName)
        {
            // 构造RowPutChange
            var rowChange = new RowPutChange();
            // 注意rowChange的主键信息必须与创建表时指定的主键个数、名称及类型均一致
            // 可以直接赋值主键为支持的类型对象,包括整型、布尔型和字符串。
            rowChange.PrimaryKeys["uid"] = 1;
            rowChange.PrimaryKeys["flag"] = true;
            rowChange.PrimaryKeys["name"] = "张三";
            //.其他属性信息放在AttributeColumns中,可以是建表时没有指定的列
            // 可以直接赋值列值为支持的类型对象,包括整型、浮点型、布尔型和字符串。
            rowChange.AttributeColumns["groupid"] = 1;
            rowChange.AttributeColumns["mobile"] = "11111111111";
            rowChange.AttributeColumns["address"] = "中国某地";
            rowChange.AttributeColumns["age"] = 20;

            // 提交数据
            var otsClient = new OtsClient(endpoint, accessId, accessKey);

            try
            {
                otsClient.PutData(tableName, rowChange);
            }
            catch (OtsException ex)
            {
                Console.WriteLine("插入数据失败。OTS异常消息: " + ex.Message);
                Console.WriteLine("Request ID: {0}\tHostID: {1}", ex.RequestId, ex.HostId);
            }
            catch (System.Net.WebException ex)
            {
                Console.WriteLine("创建表失败。网络异常:{0}。请检查Endpoint或网络链接。", ex.Message);
            }
        }
    }
}
See Also

Reference