本文整理汇总了C#中TablePayloadFormat类的典型用法代码示例。如果您正苦于以下问题:C# TablePayloadFormat类的具体用法?C# TablePayloadFormat怎么用?C# TablePayloadFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TablePayloadFormat类属于命名空间,在下文中一共展示了TablePayloadFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildRequestForTableQuery
internal static HttpWebRequest BuildRequestForTableQuery(Uri uri, UriQueryBuilder builder, int? timeout, bool useVersionHeader, OperationContext ctx, TablePayloadFormat payloadFormat)
{
HttpWebRequest msg = BuildRequestCore(uri, builder, "GET", timeout, useVersionHeader, ctx);
SetAcceptHeaderForHttpWebRequest(msg, payloadFormat);
Logger.LogInformational(ctx, SR.PayloadFormat, payloadFormat);
return msg;
}
示例2: DoListTablesSegmentedBasicAsync
private async Task DoListTablesSegmentedBasicAsync(TablePayloadFormat format)
{
CloudTableClient tableClient = GenerateCloudTableClient();
tableClient.PayloadFormat = format;
TableResultSegment segment = null;
List<CloudTable> totalResults = new List<CloudTable>();
do
{
segment = await tableClient.ListTablesSegmentedAsync(segment != null ? segment.ContinuationToken : null, CancellationToken.None);
totalResults.AddRange(segment);
}
while (segment.ContinuationToken != null);
// Assert.AreEqual(totalResults.Count, tableClient.ListTables().Count());
}
示例3: DoTableGenericQueryProjectionWithSpecialCases
public void DoTableGenericQueryProjectionWithSpecialCases(CloudTable table, TablePayloadFormat format, bool disableCompiledSerializers)
{
table.ServiceClient.DefaultRequestOptions.PayloadFormat = format;
BaseEntity.DisableCompiledSerializers = disableCompiledSerializers;
// Query on A, B, and E
TableQuery<BaseEntity> query = new TableQuery<BaseEntity>().Select(new List<string>() { "A", "B", "E" });
IEnumerable<BaseEntity> entities = table.ExecuteQuery(query, null);
// Verify A has a set value and B and E have type defaults
Assert.AreEqual(1, entities.Count());
BaseEntity entity = entities.First();
Assert.AreEqual("a", entity.A);
Assert.IsNull(entity.B);
Assert.AreEqual(0, entity.E);
}
示例4: DoTableGenericQueryEnumerateTwice
private void DoTableGenericQueryEnumerateTwice(TablePayloadFormat format)
{
tableClient.DefaultRequestOptions.PayloadFormat = format;
TableQuery<BaseEntity> query = new TableQuery<BaseEntity>();
OperationContext opContext = new OperationContext();
IEnumerable<BaseEntity> enumerable = currentTable.ExecuteQuery(query);
List<BaseEntity> firstIteration = new List<BaseEntity>();
List<BaseEntity> secondIteration = new List<BaseEntity>();
foreach (BaseEntity ent in enumerable)
{
Assert.IsTrue(ent.PartitionKey.StartsWith("tables_batch"));
ent.Validate();
firstIteration.Add(ent);
}
foreach (BaseEntity ent in enumerable)
{
Assert.IsTrue(ent.PartitionKey.StartsWith("tables_batch"));
ent.Validate();
secondIteration.Add(ent);
}
Assert.AreEqual(firstIteration.Count, secondIteration.Count);
for (int m = 0; m < firstIteration.Count; m++)
{
Assert.AreEqual(firstIteration[m].PartitionKey, secondIteration[m].PartitionKey);
Assert.AreEqual(firstIteration[m].RowKey, secondIteration[m].RowKey);
Assert.AreEqual(firstIteration[m].Timestamp, secondIteration[m].Timestamp);
Assert.AreEqual(firstIteration[m].ETag, secondIteration[m].ETag);
firstIteration[m].Validate();
}
}
示例5: DoTableGenericQueryWithContinuationSync
private void DoTableGenericQueryWithContinuationSync(TablePayloadFormat format)
{
tableClient.DefaultRequestOptions.PayloadFormat = format;
TableQuery<BaseEntity> query = new TableQuery<BaseEntity>();
OperationContext opContext = new OperationContext();
TableQuerySegment<BaseEntity> seg = currentTable.ExecuteQuerySegmented(query, null, null, opContext);
int count = 0;
foreach (BaseEntity ent in seg)
{
Assert.IsTrue(ent.PartitionKey.StartsWith("tables_batch"));
ent.Validate();
count++;
}
// Second segment
Assert.IsNotNull(seg.ContinuationToken);
seg = currentTable.ExecuteQuerySegmented(query, seg.ContinuationToken, null, opContext);
foreach (BaseEntity ent in seg)
{
Assert.IsTrue(ent.PartitionKey.StartsWith("tables_batch"));
ent.Validate();
count++;
}
Assert.AreEqual(1500, count);
TestHelper.AssertNAttempts(opContext, 2);
}
示例6: DoTableGenericQueryWithInternalType
private void DoTableGenericQueryWithInternalType(TablePayloadFormat format)
{
tableClient.DefaultRequestOptions.PayloadFormat = format;
TableQuery<InternalEntity> query = new TableQuery<InternalEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "tables_batch_1"));
TableQuerySegment<InternalEntity> seg = currentTable.ExecuteQuerySegmented(query, null);
foreach (InternalEntity ent in seg)
{
Assert.AreEqual(ent.PartitionKey, "tables_batch_1");
ent.Validate();
}
}
示例7: DoTableQueryGenericWithTakeCount
private void DoTableQueryGenericWithTakeCount(TablePayloadFormat format)
{
tableClient.DefaultRequestOptions.PayloadFormat = format;
// No continuation
TableQuery<BaseEntity> query = new TableQuery<BaseEntity>().Take(100);
OperationContext opContext = new OperationContext();
IEnumerable<BaseEntity> enumerable = currentTable.ExecuteQuery(query, null, opContext);
Assert.AreEqual(query.TakeCount, enumerable.Count());
TestHelper.AssertNAttempts(opContext, 1);
// With continuations
query.TakeCount = 1200;
opContext = new OperationContext();
enumerable = currentTable.ExecuteQuery(query, null, opContext);
Assert.AreEqual(query.TakeCount, enumerable.Count());
TestHelper.AssertNAttempts(opContext, 2);
foreach (BaseEntity entity in enumerable)
{
entity.Validate();
}
}
示例8: DoTableGenericQueryWithSpecificOnSupportedTypes
private void DoTableGenericQueryWithSpecificOnSupportedTypes(TablePayloadFormat format)
{
CloudTableClient client = GenerateCloudTableClient();
CloudTable table = client.GetTableReference(GenerateRandomTableName());
table.Create();
client.DefaultRequestOptions.PayloadFormat = format;
try
{
// Setup
TableBatchOperation batch = new TableBatchOperation();
string pk = Guid.NewGuid().ToString();
ComplexEntity middleRef = null;
for (int m = 0; m < 100; m++)
{
ComplexEntity complexEntity = new ComplexEntity(pk, string.Format("{0:0000}", m));
complexEntity.String = string.Format("{0:0000}", m);
complexEntity.Binary = new byte[] { 0x01, 0x02, (byte)m };
complexEntity.BinaryPrimitive = new byte[] { 0x01, 0x02, (byte)m };
complexEntity.Bool = m % 2 == 0 ? true : false;
complexEntity.BoolPrimitive = m % 2 == 0 ? true : false;
complexEntity.Double = m + ((double)m / 100);
complexEntity.DoublePrimitive = m + ((double)m / 100);
complexEntity.Int32 = m;
complexEntity.IntegerPrimitive = m;
complexEntity.Int64 = (long)int.MaxValue + m;
complexEntity.LongPrimitive = (long)int.MaxValue + m;
complexEntity.Guid = Guid.NewGuid();
batch.Insert(complexEntity);
if (m == 50)
{
middleRef = complexEntity;
}
// Add delay to make times unique
Thread.Sleep(100);
}
table.ExecuteBatch(batch);
// 1. Filter on String
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterCondition("String", QueryComparisons.GreaterThanOrEqual, "0050"), 50);
// 2. Filter on Guid
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForGuid("Guid", QueryComparisons.Equal, middleRef.Guid), 1);
// 3. Filter on Long
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForLong("Int64", QueryComparisons.GreaterThanOrEqual,
middleRef.LongPrimitive), 50);
ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForLong("LongPrimitive",
QueryComparisons.GreaterThanOrEqual, middleRef.LongPrimitive), 50);
// 4. Filter on Double
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForDouble("Double", QueryComparisons.GreaterThanOrEqual,
middleRef.Double), 50);
ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForDouble("DoublePrimitive",
QueryComparisons.GreaterThanOrEqual, middleRef.DoublePrimitive), 50);
// 5. Filter on Integer
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForInt("Int32", QueryComparisons.GreaterThanOrEqual,
middleRef.Int32), 50);
ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForInt("IntegerPrimitive",
QueryComparisons.GreaterThanOrEqual, middleRef.IntegerPrimitive), 50);
// 6. Filter on Date
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForDate("DateTimeOffset", QueryComparisons.GreaterThanOrEqual,
middleRef.DateTimeOffset), 50);
// 7. Filter on Boolean
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForBool("Bool", QueryComparisons.Equal, middleRef.Bool), 50);
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForBool("BoolPrimitive", QueryComparisons.Equal, middleRef.BoolPrimitive),
50);
// 8. Filter on Binary
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForBinary("Binary", QueryComparisons.Equal, middleRef.Binary), 1);
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForBinary("BinaryPrimitive", QueryComparisons.Equal,
middleRef.BinaryPrimitive), 1);
// 9. Filter on Binary GTE
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForBinary("Binary", QueryComparisons.GreaterThanOrEqual,
middleRef.Binary), 50);
//.........这里部分代码省略.........
示例9: DoTableQueryEmptyValueAsync
private async Task DoTableQueryEmptyValueAsync(TablePayloadFormat format)
{
CloudTableClient client = GenerateCloudTableClient();
client.DefaultRequestOptions.PayloadFormat = format;
CloudTable table = client.GetTableReference(GenerateRandomTableName());
await table.CreateAsync();
// Setup
string pk = Guid.NewGuid().ToString();
DynamicTableEntity dynEnt = new DynamicTableEntity(pk, "rowkey");
dynEnt.Properties.Add("A", new EntityProperty(string.Empty));
await table.ExecuteAsync(TableOperation.Insert(dynEnt));
// 1. Filter on String
List<DynamicTableEntity> results = (await table.ExecuteQuerySegmentedAsync(new TableQuery().Where(TableQuery.GenerateFilterCondition("A", QueryComparisons.Equal, string.Empty)), null)).ToList();
Assert.AreEqual(1, results.Count);
List<BaseEntity> pocoresults = (await table.ExecuteQuerySegmentedAsync(new TableQuery<BaseEntity>().Where(TableQuery.GenerateFilterCondition("A", QueryComparisons.Equal, string.Empty)), null)).ToList();
Assert.AreEqual(1, pocoresults.Count);
}
示例10: DoTableRegionalQueryOnSupportedTypesAsync
private async Task DoTableRegionalQueryOnSupportedTypesAsync(TablePayloadFormat format)
{
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");
CloudTableClient client = GenerateCloudTableClient();
client.DefaultRequestOptions.PayloadFormat = format;
CloudTable table = client.GetTableReference(GenerateRandomTableName());
await table.CreateAsync();
try
{
// Setup
TableBatchOperation batch = new TableBatchOperation();
string pk = Guid.NewGuid().ToString();
DynamicTableEntity middleRef = null;
for (int m = 0; m < 100; m++)
{
ComplexEntity complexEntity = new ComplexEntity();
complexEntity.String = string.Format("{0:0000}", m);
complexEntity.Binary = new byte[] { 0x01, 0x02, (byte)m };
complexEntity.BinaryPrimitive = new byte[] { 0x01, 0x02, (byte)m };
complexEntity.Bool = m % 2 == 0 ? true : false;
complexEntity.BoolPrimitive = m % 2 == 0 ? true : false;
complexEntity.Double = m + ((double)m / 100);
complexEntity.DoublePrimitive = m + ((double)m / 100);
complexEntity.Int32 = m;
complexEntity.IntegerPrimitive = m;
complexEntity.Int64 = (long)int.MaxValue + m;
complexEntity.LongPrimitive = (long)int.MaxValue + m;
complexEntity.Guid = Guid.NewGuid();
DynamicTableEntity dynEnt = new DynamicTableEntity(pk, string.Format("{0:0000}", m));
dynEnt.Properties = complexEntity.WriteEntity(null);
batch.Insert(dynEnt);
if (m == 50)
{
middleRef = dynEnt;
}
// Add delay to make times unique
await Task.Delay(100);
}
await table.ExecuteBatchAsync(batch);
// 1. Filter on String
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterCondition("String", QueryComparisons.GreaterThanOrEqual, "0050"), 50);
// 2. Filter on Guid
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForGuid("Guid", QueryComparisons.Equal, middleRef.Properties["Guid"].GuidValue.Value), 1);
// 3. Filter on Long
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForLong("Int64", QueryComparisons.GreaterThanOrEqual,
middleRef.Properties["LongPrimitive"].Int64Value.Value), 50);
ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForLong("LongPrimitive",
QueryComparisons.GreaterThanOrEqual, middleRef.Properties["LongPrimitive"].Int64Value.Value), 50);
// 4. Filter on Double
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForDouble("Double", QueryComparisons.GreaterThanOrEqual,
middleRef.Properties["Double"].DoubleValue.Value), 50);
ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForDouble("DoublePrimitive",
QueryComparisons.GreaterThanOrEqual, middleRef.Properties["DoublePrimitive"].DoubleValue.Value), 50);
// 5. Filter on Integer
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForInt("Int32", QueryComparisons.GreaterThanOrEqual,
middleRef.Properties["Int32"].Int32Value.Value), 50);
ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForInt("IntegerPrimitive",
QueryComparisons.GreaterThanOrEqual, middleRef.Properties["IntegerPrimitive"].Int32Value.Value), 50);
// 6. Filter on Date
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForDate("DateTimeOffset", QueryComparisons.GreaterThanOrEqual,
middleRef.Properties["DateTimeOffset"].DateTimeOffsetValue.Value), 50);
// 7. Filter on Boolean
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForBool("Bool", QueryComparisons.Equal, middleRef.Properties["Bool"].BooleanValue.Value), 50);
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForBool("BoolPrimitive", QueryComparisons.Equal, middleRef.Properties["BoolPrimitive"].BooleanValue.Value),
50);
// 8. Filter on Binary
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForBinary("Binary", QueryComparisons.Equal, middleRef.Properties["Binary"].BinaryValue), 1);
ExecuteQueryAndAssertResults(table,
TableQuery.GenerateFilterConditionForBinary("BinaryPrimitive", QueryComparisons.Equal,
middleRef.Properties["BinaryPrimitive"].BinaryValue), 1);
//.........这里部分代码省略.........
示例11: DoTableQueryProjectionAsync
private void DoTableQueryProjectionAsync(TablePayloadFormat format)
{
tableClient.DefaultRequestOptions.PayloadFormat = format;
TableQuery query = new TableQuery().Select(new List<string>() { "a", "c" });
foreach (DynamicTableEntity ent in ExecuteQuery(currentTable, query))
{
Assert.IsNotNull(ent.PartitionKey);
Assert.IsNotNull(ent.RowKey);
Assert.IsNotNull(ent.Timestamp);
Assert.AreEqual(ent.Properties["a"].StringValue, "a");
Assert.IsFalse(ent.Properties.ContainsKey("b"));
Assert.AreEqual(ent.Properties["c"].StringValue, "c");
Assert.IsFalse(ent.Properties.ContainsKey("d"));
}
}
示例12: DoTableQueryWithFilterAsync
private void DoTableQueryWithFilterAsync(TablePayloadFormat format)
{
tableClient.DefaultRequestOptions.PayloadFormat = format;
TableQuery query = new TableQuery().Where(string.Format("(PartitionKey eq '{0}') and (RowKey ge '{1}')", "tables_batch_1", "0050"));
OperationContext opContext = new OperationContext();
int count = 0;
foreach (DynamicTableEntity ent in ExecuteQuery(currentTable, query))
{
Assert.AreEqual(ent.Properties["foo"].StringValue, "bar");
Assert.AreEqual(ent.PartitionKey, "tables_batch_1");
Assert.AreEqual(ent.RowKey, string.Format("{0:0000}", count + 50));
count++;
}
Assert.AreEqual(count, 50);
}
示例13: DoTableQueryWithContinuationAsync
private async Task DoTableQueryWithContinuationAsync(TablePayloadFormat format)
{
TableQuery query = new TableQuery();
tableClient.DefaultRequestOptions.PayloadFormat = format;
OperationContext opContext = new OperationContext();
TableQuerySegment<DynamicTableEntity> seg = await currentTable.ExecuteQuerySegmentedAsync(query, null, null, opContext);
int count = 0;
foreach (DynamicTableEntity ent in seg)
{
Assert.IsTrue(ent.PartitionKey.StartsWith("tables_batch"));
Assert.AreEqual(ent.Properties.Count, 4);
count++;
}
// Second segment
Assert.IsNotNull(seg.ContinuationToken);
seg = await currentTable.ExecuteQuerySegmentedAsync(query, seg.ContinuationToken, null, opContext);
foreach (DynamicTableEntity ent in seg)
{
Assert.IsTrue(ent.PartitionKey.StartsWith("tables_batch"));
Assert.AreEqual(ent.Properties.Count, 4);
count++;
}
Assert.AreEqual(1500, count);
TestHelper.AssertNAttempts(opContext, 2);
}
示例14: DoTableQueryBasicAsync
private async Task DoTableQueryBasicAsync(TablePayloadFormat format)
{
tableClient.DefaultRequestOptions.PayloadFormat = format;
TableQuery query = new TableQuery().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "tables_batch_1"));
TableQuerySegment<DynamicTableEntity> seg = await currentTable.ExecuteQuerySegmentedAsync(query, null);
foreach (DynamicTableEntity ent in seg)
{
Assert.AreEqual(ent.PartitionKey, "tables_batch_1");
Assert.AreEqual(ent.Properties.Count, 4);
}
}
示例15: DoListTablesSegmentedWithPrefixAsync
private async Task DoListTablesSegmentedWithPrefixAsync(TablePayloadFormat format)
{
CloudTableClient tableClient = GenerateCloudTableClient();
tableClient.PayloadFormat = format;
TableResultSegment segment = null;
List<CloudTable> totalResults = new List<CloudTable>();
int segCount = 0;
do
{
segment = await tableClient.ListTablesSegmentedAsync(prefixTablesPrefix, null, segment != null ? segment.ContinuationToken : null, null, null);
totalResults.AddRange(segment);
segCount++;
}
while (segment.ContinuationToken != null);
Assert.AreEqual(totalResults.Count, 20);
foreach (CloudTable tbl in totalResults)
{
Assert.IsTrue(tbl.Name.StartsWith(prefixTablesPrefix));
}
}