Azure表存储分区键行键,如何在对应相同分区和不同rowKey的位置插入多个实体?

问题描述

我是C#.net开发人员,正在创建一个电子邮件跟踪系统。我想将数据存储到Azure表存储中,但是我想使用不同的行键在同一分区中创建所有实体。我的属性键相同,但值不同。例如:

partition key = "Test+id"
row key=123
properties:
subject:"Hello",from:"[email protected]",to:"[email protected]",body:"Hello I am a test email"

现在,我想创建一个上述副本,但具有不同的rowKey值,相同的分区键值和相同的属性键,但具有不同的值。像这样:

partition key = "Test+id",row key="787",properties:
subject: "HelloTesting",from:"[email protected]",to:"[email protected]",body: "Hello I am a test email2,this is so nice"

这是我用来添加属性的C#代码:

foreach (KeyValuePair<string,string> keyValuePair in list)
{
    dynamicTableEntity.RowKey = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.SSS");
    Console.WriteLine(keyValuePair.Key);

    if (keyValuePair.Key.Equals("subject"))
    {
        dynamicTableEntity.Properties.Add("subject",EntityProperty.CreateEntityPropertyFromObject(keyValuePair.Value));
    }
    else if (keyValuePair.Key.Equals("toRecipients") )
    {
        dynamicTableEntity.Properties.Add("toRecipients",EntityProperty.CreateEntityPropertyFromObject(keyValuePair.Value));
    }
    else if (keyValuePair.Key.Equals("from") )
    {
        dynamicTableEntity.Properties.Add("from",EntityProperty.CreateEntityPropertyFromObject(keyValuePair.Value));
    }
    else if (keyValuePair.Key.Equals("bodyPreview") )
    {
        dynamicTableEntity.Properties.Add("bodyPreview",EntityProperty.CreateEntityPropertyFromObject(keyValuePair.Value));
    }
    else
    {
        dynamicTableEntity.Properties.Add(keyValuePair.Key,EntityProperty.CreateEntityPropertyFromObject(keyValuePair.Value));
    }
}

任何帮助将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)