【发布时间】:2015-04-09 09:32:37
【问题描述】:
所以问题是: 我有一个实体,它有 40 个属性(所有在代码中正确定义为“public String PropertyName {get;set;}”。 当我插入新实体时,大部分属性都被存储了,但其中一些没有。
代码如下:
public class PostTableEntity : TableEntity
{
#region Fields
#endregion
#region Properties
public Guid CreatorId { get; set; }
public String HtmlText { get; set; }
public String SubjectIds { get; set; }
public String QuoteString { get; set; }
public double GeoLat { get; set; }
public double GeoLong { get; set; }
public String GeoPlace { get; set; }
public Int32 TotalSmiles { get; set; }
public DateTime DateUTC { get; set; }
public Guid? EventId { get; set; }
public string EventName { get; set; }
public String ExcludedUsers { get; set; }
public String Comment00_Text { get; set; }
public Guid Comment00_UserId { get; set; }
public Guid Comment00_CommentId { get; set; }
{...} //Some more props - no more than 30 in total
public String VeryImportantData { get; set; }
#endregion
#region Constructors
public PostTableEntity()
{
}
public PostTableEntity(String partitionKey, String rowKey, Guid creatorId, DateTime dateUTC, String htmlText)
: base(partitionKey, rowKey)
{
this.CreatorId = creatorId;
this.HtmlText = htmlText;
this.DateUTC = dateUTC;
}
#endregion
#region Methods
public void SetSubjectIdsList(List<Guid> subjectIds)
{
if (subjectIds != null)
{
this.SubjectIds = String.Join(";", subjectIds);
}
else
{
this.SubjectIds = "";
}
}
#endregion
}
...然后有一个派生类:
public class ImagePostTableEntity : PostTableEntity
{
#region Fields
#endregion
#region Properties
public String StorageAccountName { get; set; }
public String StorageContainerName { get; set; }
public String BlobName_Original { get; set; }
public String BlobName_Large { get; set; }
public String BlobName_Medium { get; set; }
public String BlobName_Small { get; set; }
#endregion
#region Constructors
public ImagePostTableEntity()
{
}
public ImagePostTableEntity(String partitionKey, String rowKey, Guid creatorId, DateTime date, String htmlText, List<Guid> subjectIds, String storageAccountName, String storageContainerName, String blobName_Original, String blobName_Large, String blobName_Medium, String blobName_Small)
: base(partitionKey, rowKey, creatorId, date, htmlText)
{
this.StorageAccountName = storageAccountName;
this.StorageContainerName = storageContainerName;
this.BlobName_Original = blobName_Original;
this.BlobName_Large = blobName_Large;
this.BlobName_Medium = blobName_Medium;
this.BlobName_Small = blobName_Small;
this.SetSubjectIdsList(subjectIds);
}
}
所以我这样称呼 InsertOperation(我觉得没什么特别的):
ImagePostTableEntity newPost = new ImagePostTableEntity(streamId.ToString(), newPostId.ToString(), creatorId, date, htmlText, subjectIds, storageAccountName, storageContainerName, blobName_Original, blobName_Large, blobName_Medium, blobName_Small); //This construcotr calls inner method: SetSubjectIdsList(subjectIds);
newPost.TotalComments = 0;
newPost.VeryImportantData = "That very important string";
TableOperation insertOperation = TableOperation.Insert(newPost);
此操作后,表存储中存在实体,但未存储某些属性。具体来说,只有“SubjectIds”和“VeryImportantData”不被存储。它们不为空,并且具有一定的价值(仔细检查;))
【问题讨论】:
-
实体属性中所有数据的总大小不能超过 1 MB,不确定是您的实体的问题。 msdn.microsoft.com/en-us/library/azure/dd179338.aspx
-
好的,新信息 ;):我删除了 azure 存储表,然后创建了一个同名:“posts”。然后它仍然不起作用,但是当我创建一个新表“posts2”时,它突然开始存储所有数据。有什么想法吗?
-
@DSR - 感谢您的回复。存储的数据不可能超过 1 MB。有 40 个属性,每个属性最多 64 个字节 = 40*64 字节;)。那么就不是这样了。
-
@KrzysztofRudnicki - 40*64kb 所以你可能已经超过 1MB。您是针对模拟器还是存储帐户运行?你有任何形式的例外吗?
-
您能否在代码 sn-p 上方添加您实际执行插入操作的方式?
标签: c# azure-storage azure-table-storage