gpt4 book ai didi

c# - ServiceContext.SaveChangesWithRetries 与 SaveChangesOptions.Batch 异常

转载 作者:行者123 更新时间:2023-12-02 08:10:04 27 4
gpt4 key购买 nike

我正在尝试使用批处理选项将实体保存在 azure 存储表中

这是代码:

foreach (TableEntity entity in entitiesList)
{
ServiceContext.AddObject(entity.getTableName(), entity);
}

ServiceContext.SaveChangesWithRetries(SaveChangesOptions.Batch);

我收到此异常:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>InvalidInput</code>
<message xml:lang="en-US">99:One of the request inputs is not valid.
RequestId:b54a78fe-30ae-427e-86e9-6107d6e3fe5a
Time:2013-01-14T15:50:17.0134794Z</message>
</error>

但是当我尝试在单独的查询中添加每个实体时,它会起作用

但我不明白的是,当我使用“Azure Storage Explorer”检查azure sotage帐户上的表时,我发现了我正在尝试加载的数据!!

任何人都可以解释为什么我在 azure 表上找到了数据,尽管我有一个异常,以及如何修复它,以便在 ServiceContext.SaveChangesWithRetries 方法中使用批处理选项

提前感谢您的帮助

最佳答案

批量选项仅支持添加最多 100 个只有一个 PartitionKey 的实体。请确保您保存的实体不超过 100 个,并且所有实体都包含一个 key 。

请在此处查找有关批量实体交易的更多信息: http://msdn.microsoft.com/en-us/library/windowsazure/dd894038.aspx

关于c# - ServiceContext.SaveChangesWithRetries 与 SaveChangesOptions.Batch 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14322021/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com