Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

c# - Table entities not being serialized properly after upgrade to Microsoft.WindowsAzure.Storage 4.0.0

I have a C#.NET Web API project that works with Azure Table Storage. Some of the methods returns lists of various table entities. Until I upgraded to Microsoft.WindowsAzure.Storage 4.0.0 everything worked just fine. Now only the base properties (PartitionKey, RowKey,Timestamp, and ETag) are returned and my own custom properties are ignored, i.e., not serialized.

I note that in the change log for Microsoft.WindowsAzure.Storage 4.0.0 there is an entry that seems like it might have something to do with this:

  • Tables: TableEntity is serializable via the ISerializable interface.

In response to this I tried decorating my table entity class with [Serializable] and my custom properties with [DataMember]. An example:

[Serializable]
public class UserGroup : TableEntity
{
    public UserGroup(String PartitionKey, String RowKey)
        : base(PartitionKey, RowKey)
    {
        this.PartitionKey = PartitionKey;
        this.RowKey = RowKey;
    }

    public UserGroup()
    {
    }

    [DataMember]
    public String Name { get; set; }
    [DataMember]
    public String ShortName { get; set; }
    [DataMember]
    public String LicenseGuid { get; set; }
}

Still, only the base properties are returned, and my custom properties (Name, ShortName, and LicenseGuid) and not included in the JSON response from the Web API method.

Any ideas? (I'm going back to Microsoft.WindowsAzure.Storage 3.2.1 for now)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This issue has now been fixed in our latest release that you can grab from here - http://www.nuget.org/packages/WindowsAzure.Storage


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...