2. Table Storage: It stores data in the form of key-value. The maximum size of each record is 4 MB, and there is no limit on the number of records.
(1) entity operation. Entity operations are performed on tableservicecontext (inherited from dataservicecontext) obtained from cloudtableclient. The addobject (), updateojbect (), and deleteobject () methods are called for addition, update, and deletion. Only the addobject method needs to specify the table name of the operation. After the methods are called for entity Operations, you must call the savechanage () method to save the operation results.
Example of adding entity:
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount; CloudTableClient tableclient = storageAccount.CreateCloudTableClient(); tableclient.CreateTableIfNotExist("tabletest"); TableServiceContext context = tableclient.GetDataServiceContext(); context.AddObject("tabletest", new PersonInfo() { PersonID = "0", Name = "Tom", Age = 20 }); context.AddObject("tabletest", new PersonInfo() { PersonID = "1", Name = "Jerry", Age = 25 }); context.SaveChanges();
(2) query table records. Table query is a query executed using a LINQ Statement by calling the createquery () method of tableservicecontext.
Table query example:
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount; CloudTableClient tableclient = storageAccount.CreateCloudTableClient(); tableclient.CreateTableIfNotExist("tabletest"); TableServiceContext context = tableclient.GetDataServiceContext(); var query = context.CreateQuery<PersonInfo>("tabletest").Where(c => c.PersonID == "1").ToList(); var info = query.FirstOrDefault();
The personinfo type definition used in the preceding sample code.
public class PersonInfo : TableServiceEntity { public string PersonID { get { return this.RowKey; } set { this.RowKey = value; } } public string Name { get; set; } public int Age { get; set; } public PersonInfo() { this.PartitionKey = "PartKey"; } }
(3) Table operation performance curve
A. The performance curves for adding, updating, and deleting records are shown in. We can analyze the linear relationship between the number of records and the consumed time, but it takes nearly 20 seconds for 100 data records, A little scary (this may be related to the operation record size and the location of the ECS deployed in webrole ).
B. the query performance curve is as good as the query performance.