locked
BitArray in Azure Table Storage RRS feed

  • Question

  • Environment: Windows Azure v1.1, ASP.NET 3.5, C#, JavaScript, VS2008 SP1

    I have a simple Azure Table (TableServiceEntity) with the following columns (in addtion to Partition key/Row key/Timestamp)
    public double Reputation { get; set; }
    public int Badges { get; set; }
    public BitArray BitArrayBadges { get; set; }

    I want to insert a new record roughly as follows:
    from my create-record method...

    int userId = "100200300"; // I generate a unique string for each method call
    BitArray bitArrayBadges = new BitArray(13, false);
    int badges = 0;
    MyDataSource urds = new MyDataSource();     // contains CloudStorageAccount and TableServiceContext instances
    MyDataModel urdm = new MyDataModel(userID); // derived from TableServiceEntity
    urdm.BitArrayBadges = bitArrayBadges;
    urdm.Badges = badges; // no badges initially
    urdm.Reputation = 0.0;
    urds.Insert(urdm);

    The insert method (below), fails on SaveChanges
    public void Insert(MyDataModel newItem)
      {
         _ServiceContext.AddObject(MyTableServiceContext.UserReputationTableName, newItem);
         _ServiceContext.SaveChanges();
      }
    with the following stack trace
    [System.Data.Services.Client.DataServiceClientException]
    "System.InvalidOperationException: The type 'System.Object' has no settable properties.\r\n  
    at System.Data.Services.Client.ClientType..ctor(Type type, String typeName, Boolean skipSettableCheck)\r\n  
    at System.Data.Services.Client.ClientType.Create(Type type, Boolean expectModelType)\r\n  
    at System.Data.Services.Client.ClientType.Create(Type type)\r\n  
    at System.Data.Services.Client.DataServiceContext.WriteContentProperties(XmlWriter writer, ClientType type, Object resource)\r\n  
    at System.Data.Services.Client.DataServiceContext.WriteContentProperties(XmlWriter writer, ClientType type, Object resource)\r\n  
    at System.Data.Services.Client.DataServiceContext.CreateRequestData(ResourceBox box, Boolean newline)\r\n  
    at System.Data.Services.Client.DataServiceContext.SaveAsyncResult.CreateChangeData(Int32 index, Boolean newline)\r\n  
    at System.Data.Services.Client.DataServiceContext.SaveAsyncResult.BeginNextChange(Boolean replaceOnUpdate)\r\n\r\n" 
    System.Data.Services.Client.DataServiceClientException


    If I change my TableServiceEntity (MyDataModel) by removing BitArrayBadges (and not setting it in my method before Save), then all is well.

    Can I have a BitArray firld in my TableServiceEntity? If so, how do I best change my approach?

    Thursday, August 19, 2010 7:42 PM

Answers

All replies

  • The supported Table Service datatypes are:

    • Boolean
    • Byte[]
    • DateTime
    • Double
    • Int32
    • Int64
    • String

    BitArray is not supported.

    Thursday, August 19, 2010 8:19 PM
    Answerer
  • Thanks Neil.

    (It would be nice if VS2008 gave me a better design-time indication of the incompatibility though ;)

    Friday, August 20, 2010 4:09 PM