本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Table.Entities.ComplexEntity类的典型用法代码示例。如果您正苦于以下问题:C# ComplexEntity类的具体用法?C# ComplexEntity怎么用?C# ComplexEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComplexEntity类属于Microsoft.WindowsAzure.Storage.Table.Entities命名空间,在下文中一共展示了ComplexEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
//.........这里部分代码省略.........
示例2: MyClassInitialize
public static void MyClassInitialize(TestContext testContext)
{
CloudTableClient tableClient = GenerateCloudTableClient();
currentTable = tableClient.GetTableReference(GenerateRandomTableName());
currentTable.CreateIfNotExists();
// Bulk Query Entities
for (int i = 0; i < 15; i++)
{
TableBatchOperation batch = new TableBatchOperation();
for (int j = 0; j < 100; j++)
{
var ent = GenerateRandomEnitity("tables_batch_" + i.ToString());
ent.RowKey = string.Format("{0:0000}", j);
batch.Insert(ent);
}
currentTable.ExecuteBatch(batch);
}
complexEntityTable = tableClient.GetTableReference(GenerateRandomTableName());
complexEntityTable.Create();
// Setup
TableBatchOperation complexBatch = new TableBatchOperation();
string pk = Guid.NewGuid().ToString();
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.Int32N = m;
complexEntity.IntegerPrimitive = m;
complexEntity.IntegerPrimitiveN = m;
complexEntity.Int64 = (long)int.MaxValue + m;
complexEntity.LongPrimitive = (long)int.MaxValue + m;
complexEntity.LongPrimitiveN = (long)int.MaxValue + m;
complexEntity.Guid = Guid.NewGuid();
complexBatch.Insert(complexEntity);
if (m == 50)
{
middleRef = complexEntity;
}
// Add delay to make times unique
Thread.Sleep(100);
}
complexEntityTable.ExecuteBatch(complexBatch);
}
示例3: 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);
//.........这里部分代码省略.........
示例4: AssertEquality
public static void AssertEquality(ComplexEntity a, ComplexEntity b)
{
Assert.AreEqual(a.String, b.String);
Assert.AreEqual(a.Int64, b.Int64);
Assert.AreEqual(a.LongPrimitive, b.LongPrimitive);
Assert.AreEqual(a.Int32, b.Int32);
Assert.AreEqual(a.IntegerPrimitive, b.IntegerPrimitive);
Assert.AreEqual(a.Guid, b.Guid);
Assert.AreEqual(a.Double, b.Double);
Assert.AreEqual(a.DoublePrimitive, b.DoublePrimitive);
Assert.AreEqual(a.BinaryPrimitive, b.BinaryPrimitive);
Assert.AreEqual(a.Binary, b.Binary);
Assert.AreEqual(a.BoolPrimitive, b.BoolPrimitive);
Assert.AreEqual(a.Bool, b.Bool);
Assert.AreEqual(a.DateTimeOffsetN, b.DateTimeOffsetN);
Assert.AreEqual(a.DateTimeOffset, b.DateTimeOffset);
Assert.AreEqual(a.DateTime, b.DateTime);
Assert.AreEqual(a.DateTimeN, b.DateTimeN);
}
示例5: TableOperationInsertSingleQuoteAsync
public async Task TableOperationInsertSingleQuoteAsync()
{
CloudTableClient tableClient = GenerateCloudTableClient();
DynamicTableEntity ent = new DynamicTableEntity() { PartitionKey = "partition'key", RowKey = "row'key" };
ent.Properties.Add("stringprop", new EntityProperty("string'value"));
await currentTable.ExecuteAsync(TableOperation.InsertOrReplace(ent));
TableQuery<DynamicTableEntity> query = new TableQuery<DynamicTableEntity>().Where(TableQuery.CombineFilters(
(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, ent.PartitionKey)),
TableOperators.And,
(TableQuery.GenerateFilterCondition("stringprop", QueryComparisons.Equal, ent.Properties["stringprop"].StringValue))));
TableQuerySegment<DynamicTableEntity> seg = await currentTable.ExecuteQuerySegmentedAsync(query, null);
foreach (DynamicTableEntity retrievedEntity in seg)
{
Assert.IsNotNull(retrievedEntity);
Assert.AreEqual(ent.PartitionKey, retrievedEntity.PartitionKey);
Assert.AreEqual(ent.RowKey, retrievedEntity.RowKey);
Assert.AreEqual(ent.Properties["stringprop"].StringValue, retrievedEntity.Properties["stringprop"].StringValue);
}
ComplexEntity complexEntity = new ComplexEntity() { PartitionKey = "partition'key", RowKey = "row'key" };
await currentTable.ExecuteAsync(TableOperation.InsertOrReplace(complexEntity));
TableQuery<ComplexEntity> query2 = new TableQuery<ComplexEntity>().Where(TableQuery.CombineFilters(
(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, ent.PartitionKey)),
TableOperators.And,
(TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, ent.RowKey))));
TableQuerySegment<ComplexEntity> seg2 = await currentTable.ExecuteQuerySegmentedAsync(query2, null);
foreach (ComplexEntity retrievedComplexEntity in seg2)
{
Assert.IsNotNull(retrievedComplexEntity);
Assert.AreEqual(ent.PartitionKey, retrievedComplexEntity.PartitionKey);
Assert.AreEqual(ent.RowKey, retrievedComplexEntity.RowKey);
}
}
示例6: TableRetrieveSyncWithReflection
public void TableRetrieveSyncWithReflection()
{
CloudTableClient tableClient = GenerateCloudTableClient();
string pk = Guid.NewGuid().ToString();
string rk = Guid.NewGuid().ToString();
ComplexEntity sendEnt = new ComplexEntity(pk, rk);
sendEnt.Binary = new Byte[] { 5, 6, 7, 8 };
sendEnt.BinaryNull = null;
sendEnt.BinaryPrimitive = new byte[] { 5, 6, 7, 8 };
sendEnt.Bool = true;
sendEnt.BoolN = true;
sendEnt.BoolNull = null;
sendEnt.BoolPrimitive = true;
sendEnt.BoolPrimitiveN = true;
sendEnt.BoolPrimitiveNull = null;
sendEnt.DateTime = DateTime.UtcNow.AddMinutes(1);
sendEnt.DateTimeN = DateTime.UtcNow.AddMinutes(1);
sendEnt.DateTimeNull = null;
sendEnt.DateTimeOffset = DateTimeOffset.Now.AddMinutes(1);
sendEnt.DateTimeOffsetN = DateTimeOffset.Now.AddMinutes(1);
sendEnt.DateTimeOffsetNull = null;
sendEnt.Double = (Double)5678.5678;
sendEnt.DoubleN = (Double)5678.5678;
sendEnt.DoubleNull = null;
sendEnt.DoublePrimitive = (double)5678.5678;
sendEnt.DoublePrimitiveN = (double)5678.5678;
sendEnt.DoublePrimitiveNull = null;
sendEnt.Guid = Guid.NewGuid();
sendEnt.GuidN = Guid.NewGuid();
sendEnt.GuidNull = null;
sendEnt.Int32 = 5678;
sendEnt.Int32N = 5678;
sendEnt.Int32Null = null;
sendEnt.Int64 = (long)5678;
sendEnt.Int64N = (long)5678;
sendEnt.Int64Null = null;
sendEnt.IntegerPrimitive = 5678;
sendEnt.IntegerPrimitiveN = 5678;
sendEnt.IntegerPrimitiveNull = null;
sendEnt.LongPrimitive = 5678;
sendEnt.LongPrimitiveN = 5678;
sendEnt.LongPrimitiveNull = null;
sendEnt.String = "ResetTestTotested";
currentTable.Execute(TableOperation.Insert(sendEnt));
TableQuery<ComplexEntity> query = new TableQuery<ComplexEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, pk));
IEnumerable<ComplexEntity> result = currentTable.ExecuteQuery(query);
ComplexEntity retrievedEntity = result.ToList().First() as ComplexEntity;
Assert.AreEqual(sendEnt.String, retrievedEntity.String);
Assert.AreEqual(sendEnt.Int64, retrievedEntity.Int64);
Assert.AreEqual(sendEnt.Int64N, retrievedEntity.Int64N);
Assert.AreEqual(sendEnt.Int64Null, retrievedEntity.Int64Null);
Assert.AreEqual(sendEnt.LongPrimitive, retrievedEntity.LongPrimitive);
Assert.AreEqual(sendEnt.LongPrimitiveN, retrievedEntity.LongPrimitiveN);
Assert.AreEqual(sendEnt.LongPrimitiveNull, retrievedEntity.LongPrimitiveNull);
Assert.AreEqual(sendEnt.Int32, retrievedEntity.Int32);
Assert.AreEqual(sendEnt.Int32N, retrievedEntity.Int32N);
Assert.AreEqual(sendEnt.Int32Null, retrievedEntity.Int32Null);
Assert.AreEqual(sendEnt.IntegerPrimitive, retrievedEntity.IntegerPrimitive);
Assert.AreEqual(sendEnt.IntegerPrimitiveN, retrievedEntity.IntegerPrimitiveN);
Assert.AreEqual(sendEnt.IntegerPrimitiveNull, retrievedEntity.IntegerPrimitiveNull);
Assert.AreEqual(sendEnt.Guid, retrievedEntity.Guid);
Assert.AreEqual(sendEnt.GuidN, retrievedEntity.GuidN);
Assert.AreEqual(sendEnt.GuidNull, retrievedEntity.GuidNull);
Assert.AreEqual(sendEnt.Double, retrievedEntity.Double);
Assert.AreEqual(sendEnt.DoubleN, retrievedEntity.DoubleN);
Assert.AreEqual(sendEnt.DoubleNull, retrievedEntity.DoubleNull);
Assert.AreEqual(sendEnt.DoublePrimitive, retrievedEntity.DoublePrimitive);
Assert.AreEqual(sendEnt.DoublePrimitiveN, retrievedEntity.DoublePrimitiveN);
Assert.AreEqual(sendEnt.DoublePrimitiveNull, retrievedEntity.DoublePrimitiveNull);
Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(0), retrievedEntity.BinaryPrimitive.GetValue(0));
Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(1), retrievedEntity.BinaryPrimitive.GetValue(1));
Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(2), retrievedEntity.BinaryPrimitive.GetValue(2));
Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(3), retrievedEntity.BinaryPrimitive.GetValue(3));
Assert.AreEqual(sendEnt.BinaryNull, retrievedEntity.BinaryNull);
Assert.AreEqual(sendEnt.Binary.GetValue(0), retrievedEntity.Binary.GetValue(0));
Assert.AreEqual(sendEnt.Binary.GetValue(1), retrievedEntity.Binary.GetValue(1));
Assert.AreEqual(sendEnt.Binary.GetValue(2), retrievedEntity.Binary.GetValue(2));
Assert.AreEqual(sendEnt.Binary.GetValue(3), retrievedEntity.Binary.GetValue(3));
Assert.AreEqual(sendEnt.BoolPrimitive, retrievedEntity.BoolPrimitive);
Assert.AreEqual(sendEnt.BoolPrimitiveN, retrievedEntity.BoolPrimitiveN);
Assert.AreEqual(sendEnt.BoolPrimitiveNull, retrievedEntity.BoolPrimitiveNull);
Assert.AreEqual(sendEnt.Bool, retrievedEntity.Bool);
Assert.AreEqual(sendEnt.BoolN, retrievedEntity.BoolN);
Assert.AreEqual(sendEnt.BoolNull, retrievedEntity.BoolNull);
Assert.AreEqual(sendEnt.DateTimeOffset, retrievedEntity.DateTimeOffset);
Assert.AreEqual(sendEnt.DateTimeOffsetN, retrievedEntity.DateTimeOffsetN);
Assert.AreEqual(sendEnt.DateTimeOffsetNull, retrievedEntity.DateTimeOffsetNull);
//.........这里部分代码省略.........
示例7: AssertEquality
public static void AssertEquality(ComplexEntity a, ComplexEntity b)
{
Assert.AreEqual(a.String, b.String);
Assert.AreEqual(a.Int64, b.Int64);
Assert.AreEqual(a.Int64N, b.Int64N);
Assert.AreEqual(a.Int64Null, b.Int64Null);
Assert.AreEqual(a.LongPrimitive, b.LongPrimitive);
Assert.AreEqual(a.LongPrimitiveN, b.LongPrimitiveN);
Assert.AreEqual(a.LongPrimitiveNull, b.LongPrimitiveNull);
Assert.AreEqual(a.Int32, b.Int32);
Assert.AreEqual(a.Int32N, b.Int32N);
Assert.AreEqual(a.Int32Null, b.Int32Null);
Assert.AreEqual(a.IntegerPrimitive, b.IntegerPrimitive);
Assert.AreEqual(a.integerPrimitiveN, b.IntegerPrimitiveN);
Assert.AreEqual(a.IntegerPrimitiveNull, b.IntegerPrimitiveNull);
Assert.AreEqual(a.Guid, b.Guid);
Assert.AreEqual(a.GuidN, b.GuidN);
Assert.AreEqual(a.GuidNull, b.GuidNull);
Assert.AreEqual(a.Double, b.Double);
Assert.AreEqual(a.DoubleN, b.DoubleN);
Assert.AreEqual(a.DoubleNull, b.DoubleNull);
Assert.AreEqual(a.DoublePrimitive, b.DoublePrimitive);
Assert.AreEqual(a.DoublePrimitiveN, b.DoublePrimitiveN);
Assert.AreEqual(a.DoublePrimitiveNull, b.DoublePrimitiveNull);
Assert.AreEqual(a.BinaryPrimitive.GetValue(0), b.BinaryPrimitive.GetValue(0));
Assert.AreEqual(a.BinaryPrimitive.GetValue(1), b.BinaryPrimitive.GetValue(1));
Assert.AreEqual(a.BinaryPrimitive.GetValue(2), b.BinaryPrimitive.GetValue(2));
Assert.AreEqual(a.BinaryPrimitive.GetValue(3), b.BinaryPrimitive.GetValue(3));
Assert.AreEqual(a.Binary.GetValue(0), b.Binary.GetValue(0));
Assert.AreEqual(a.Binary.GetValue(1), b.Binary.GetValue(1));
Assert.AreEqual(a.Binary.GetValue(2), b.Binary.GetValue(2));
Assert.AreEqual(a.Binary.GetValue(3), b.Binary.GetValue(3));
Assert.AreEqual(a.BoolPrimitive, b.BoolPrimitive);
Assert.AreEqual(a.BoolPrimitiveN, b.BoolPrimitiveN);
Assert.AreEqual(a.BoolPrimitiveNull, b.BoolPrimitiveNull);
Assert.AreEqual(a.Bool, b.Bool);
Assert.AreEqual(a.BoolN, b.BoolN);
Assert.AreEqual(a.BoolNull, b.BoolNull);
Assert.AreEqual(a.DateTimeOffsetN, b.DateTimeOffsetN);
Assert.AreEqual(a.DateTimeOffset, b.DateTimeOffset);
Assert.AreEqual(a.DateTimeOffsetNull, b.DateTimeOffsetNull);
Assert.AreEqual(a.DateTime, b.DateTime);
Assert.AreEqual(a.DateTimeN, b.DateTimeN);
Assert.AreEqual(a.DateTimeNull, b.DateTimeNull);
}
示例8: DoTableOperationInsertSingleQuoteSync
private void DoTableOperationInsertSingleQuoteSync(TablePayloadFormat format)
{
tableClient.DefaultRequestOptions.PayloadFormat = format;
DynamicTableEntity ent = new DynamicTableEntity() { PartitionKey = "partition'key", RowKey = "row'key" };
ent.Properties.Add("stringprop", new EntityProperty("string'value"));
currentTable.Execute(TableOperation.InsertOrReplace(ent));
TableQuery<DynamicTableEntity> query = new TableQuery<DynamicTableEntity>().Where(TableQuery.CombineFilters(
(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, ent.PartitionKey)),
TableOperators.And,
(TableQuery.GenerateFilterCondition("stringprop", QueryComparisons.Equal, ent.Properties["stringprop"].StringValue))));
foreach (DynamicTableEntity retrievedEntity in currentTable.ExecuteQuery(query))
{
Assert.IsNotNull(retrievedEntity);
Assert.AreEqual(ent.PartitionKey, retrievedEntity.PartitionKey);
Assert.AreEqual(ent.RowKey, retrievedEntity.RowKey);
Assert.AreEqual(ent.Properties["stringprop"].StringValue, retrievedEntity.Properties["stringprop"].StringValue);
}
// Check the iqueryable way.
IEnumerable<DynamicTableEntity> result = (from entity in currentTable.CreateQuery<DynamicTableEntity>()
where entity.PartitionKey == ent.PartitionKey && entity.Properties["stringprop"].StringValue == ent.Properties["stringprop"].StringValue
select entity);
foreach (DynamicTableEntity retrievedEntity in result.ToList())
{
Assert.IsNotNull(retrievedEntity);
Assert.AreEqual(ent.PartitionKey, retrievedEntity.PartitionKey);
Assert.AreEqual(ent.RowKey, retrievedEntity.RowKey);
Assert.AreEqual(ent.Properties["stringprop"].StringValue, retrievedEntity.Properties["stringprop"].StringValue);
}
ComplexEntity tableEntity = new ComplexEntity() { PartitionKey = "partition'key", RowKey = "row'key" };
currentTable.Execute(TableOperation.InsertOrReplace(tableEntity));
TableQuery<ComplexEntity> query2 = new TableQuery<ComplexEntity>().Where(TableQuery.CombineFilters(
(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, ent.PartitionKey)),
TableOperators.And,
(TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, ent.RowKey))));
foreach (ComplexEntity retrievedComplexEntity in currentTable.ExecuteQuery(query2))
{
Assert.IsNotNull(retrievedComplexEntity);
Assert.AreEqual(ent.PartitionKey, retrievedComplexEntity.PartitionKey);
Assert.AreEqual(ent.RowKey, retrievedComplexEntity.RowKey);
Assert.AreEqual(tableEntity.Int64, retrievedComplexEntity.Int64);
}
}
示例9: TableEntityCompiledVSReflectionSerializationEqualityTest
public void TableEntityCompiledVSReflectionSerializationEqualityTest()
{
string pk = Guid.NewGuid().ToString();
string rk = Guid.NewGuid().ToString();
ComplexEntity sendEnt = new ComplexEntity(pk, rk);
sendEnt.Binary = new Byte[] { 5, 6, 7, 8 };
sendEnt.BinaryNull = null;
sendEnt.BinaryPrimitive = new byte[] { 5, 6, 7, 8 };
sendEnt.Bool = true;
sendEnt.BoolN = true;
sendEnt.BoolNull = null;
sendEnt.BoolPrimitive = true;
sendEnt.BoolPrimitiveN = true;
sendEnt.BoolPrimitiveNull = null;
sendEnt.DateTime = DateTime.UtcNow.AddMinutes(1);
sendEnt.DateTimeN = DateTime.UtcNow.AddMinutes(1);
sendEnt.DateTimeNull = null;
sendEnt.DateTimeOffset = DateTimeOffset.Now.AddMinutes(1);
sendEnt.DateTimeOffsetN = DateTimeOffset.Now.AddMinutes(1);
sendEnt.DateTimeOffsetNull = null;
sendEnt.Double = (Double)5678.5678;
sendEnt.DoubleN = (Double)5678.5678;
sendEnt.DoubleNull = null;
sendEnt.DoublePrimitive = (double)5678.5678;
sendEnt.DoublePrimitiveN = (double)5678.5678;
sendEnt.DoublePrimitiveNull = null;
sendEnt.Guid = Guid.NewGuid();
sendEnt.GuidN = Guid.NewGuid();
sendEnt.GuidNull = null;
sendEnt.Int32 = 5678;
sendEnt.Int32N = 5678;
sendEnt.Int32Null = null;
sendEnt.Int64 = (long)5678;
sendEnt.Int64N = (long)5678;
sendEnt.Int64Null = null;
sendEnt.IntegerPrimitive = 5678;
sendEnt.IntegerPrimitiveN = 5678;
sendEnt.IntegerPrimitiveNull = null;
sendEnt.LongPrimitive = 5678;
sendEnt.LongPrimitiveN = 5678;
sendEnt.LongPrimitiveNull = null;
sendEnt.String = "ResetTestTotested";
TableEntity.DisableCompiledSerializers = true;
var reflectionDict = sendEnt.WriteEntity(null);
Assert.IsNull(sendEnt.CompiledWrite);
TableEntity.DisableCompiledSerializers = false;
var compiledDict = sendEnt.WriteEntity(null);
Assert.IsNotNull(sendEnt.CompiledWrite);
// Assert Serialized Dictionaries are the same
Assert.AreEqual(reflectionDict.Count, compiledDict.Count);
foreach (var kvp in reflectionDict)
{
Assert.IsTrue(compiledDict.ContainsKey(kvp.Key));
Assert.AreEqual(reflectionDict[kvp.Key], compiledDict[kvp.Key]);
}
}
示例10: DoTableRetrieveSyncWithReflection
private void DoTableRetrieveSyncWithReflection(TablePayloadFormat format)
{
tableClient.DefaultRequestOptions.PayloadFormat = format;
string pk = Guid.NewGuid().ToString();
string rk = Guid.NewGuid().ToString();
ComplexEntity sendEnt = new ComplexEntity(pk, rk);
sendEnt.Binary = new Byte[] { 5, 6, 7, 8 };
sendEnt.BinaryNull = null;
sendEnt.BinaryPrimitive = new byte[] { 5, 6, 7, 8 };
sendEnt.Bool = true;
sendEnt.BoolN = true;
sendEnt.BoolNull = null;
sendEnt.BoolPrimitive = true;
sendEnt.BoolPrimitiveN = true;
sendEnt.BoolPrimitiveNull = null;
sendEnt.DateTime = DateTime.UtcNow.AddMinutes(1);
sendEnt.DateTimeN = DateTime.UtcNow.AddMinutes(1);
sendEnt.DateTimeNull = null;
sendEnt.DateTimeOffset = DateTimeOffset.Now.AddMinutes(1);
sendEnt.DateTimeOffsetN = DateTimeOffset.Now.AddMinutes(1);
sendEnt.DateTimeOffsetNull = null;
sendEnt.Double = (Double)5678.5678;
sendEnt.DoubleN = (Double)5678.5678;
sendEnt.DoubleNull = null;
sendEnt.DoublePrimitive = (double)5678.5678;
sendEnt.DoublePrimitiveN = (double)5678.5678;
sendEnt.DoublePrimitiveNull = null;
sendEnt.Guid = Guid.NewGuid();
sendEnt.GuidN = Guid.NewGuid();
sendEnt.GuidNull = null;
sendEnt.Int32 = 5678;
sendEnt.Int32N = 5678;
sendEnt.Int32Null = null;
sendEnt.Int64 = (long)5678;
sendEnt.Int64N = (long)5678;
sendEnt.Int64Null = null;
sendEnt.IntegerPrimitive = 5678;
sendEnt.IntegerPrimitiveN = 5678;
sendEnt.IntegerPrimitiveNull = null;
sendEnt.LongPrimitive = 5678;
sendEnt.LongPrimitiveN = 5678;
sendEnt.LongPrimitiveNull = null;
sendEnt.String = "ResetTestTotested";
currentTable.Execute(TableOperation.Insert(sendEnt));
TableResult res = currentTable.Execute(TableOperation.Retrieve<ComplexEntity>(sendEnt.PartitionKey, sendEnt.RowKey));
ComplexEntity retrievedEntity = res.Result as ComplexEntity;
Assert.AreEqual(sendEnt.String, retrievedEntity.String);
Assert.AreEqual(sendEnt.Int64, retrievedEntity.Int64);
Assert.AreEqual(sendEnt.Int64N, retrievedEntity.Int64N);
Assert.AreEqual(sendEnt.Int64Null, retrievedEntity.Int64Null);
Assert.AreEqual(sendEnt.LongPrimitive, retrievedEntity.LongPrimitive);
Assert.AreEqual(sendEnt.LongPrimitiveN, retrievedEntity.LongPrimitiveN);
Assert.AreEqual(sendEnt.LongPrimitiveNull, retrievedEntity.LongPrimitiveNull);
Assert.AreEqual(sendEnt.Int32, retrievedEntity.Int32);
Assert.AreEqual(sendEnt.Int32N, retrievedEntity.Int32N);
Assert.AreEqual(sendEnt.Int32Null, retrievedEntity.Int32Null);
Assert.AreEqual(sendEnt.IntegerPrimitive, retrievedEntity.IntegerPrimitive);
Assert.AreEqual(sendEnt.IntegerPrimitiveN, retrievedEntity.IntegerPrimitiveN);
Assert.AreEqual(sendEnt.IntegerPrimitiveNull, retrievedEntity.IntegerPrimitiveNull);
Assert.AreEqual(sendEnt.Guid, retrievedEntity.Guid);
Assert.AreEqual(sendEnt.GuidN, retrievedEntity.GuidN);
Assert.AreEqual(sendEnt.GuidNull, retrievedEntity.GuidNull);
Assert.AreEqual(sendEnt.Double, retrievedEntity.Double);
Assert.AreEqual(sendEnt.DoubleN, retrievedEntity.DoubleN);
Assert.AreEqual(sendEnt.DoubleNull, retrievedEntity.DoubleNull);
Assert.AreEqual(sendEnt.DoublePrimitive, retrievedEntity.DoublePrimitive);
Assert.AreEqual(sendEnt.DoublePrimitiveN, retrievedEntity.DoublePrimitiveN);
Assert.AreEqual(sendEnt.DoublePrimitiveNull, retrievedEntity.DoublePrimitiveNull);
Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(0), retrievedEntity.BinaryPrimitive.GetValue(0));
Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(1), retrievedEntity.BinaryPrimitive.GetValue(1));
Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(2), retrievedEntity.BinaryPrimitive.GetValue(2));
Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(3), retrievedEntity.BinaryPrimitive.GetValue(3));
Assert.AreEqual(sendEnt.BinaryNull, retrievedEntity.BinaryNull);
Assert.AreEqual(sendEnt.Binary.GetValue(0), retrievedEntity.Binary.GetValue(0));
Assert.AreEqual(sendEnt.Binary.GetValue(1), retrievedEntity.Binary.GetValue(1));
Assert.AreEqual(sendEnt.Binary.GetValue(2), retrievedEntity.Binary.GetValue(2));
Assert.AreEqual(sendEnt.Binary.GetValue(3), retrievedEntity.Binary.GetValue(3));
Assert.AreEqual(sendEnt.BoolPrimitive, retrievedEntity.BoolPrimitive);
Assert.AreEqual(sendEnt.BoolPrimitiveN, retrievedEntity.BoolPrimitiveN);
Assert.AreEqual(sendEnt.BoolPrimitiveNull, retrievedEntity.BoolPrimitiveNull);
Assert.AreEqual(sendEnt.Bool, retrievedEntity.Bool);
Assert.AreEqual(sendEnt.BoolN, retrievedEntity.BoolN);
Assert.AreEqual(sendEnt.BoolNull, retrievedEntity.BoolNull);
Assert.AreEqual(sendEnt.DateTimeOffset, retrievedEntity.DateTimeOffset);
Assert.AreEqual(sendEnt.DateTimeOffsetN, retrievedEntity.DateTimeOffsetN);
Assert.AreEqual(sendEnt.DateTimeOffsetNull, retrievedEntity.DateTimeOffsetNull);
Assert.AreEqual(sendEnt.DateTime, retrievedEntity.DateTime);
//.........这里部分代码省略.........
示例11: TableRetrieveEntityPropertySetter
public void TableRetrieveEntityPropertySetter()
{
CloudTableClient tableClient = GenerateCloudTableClient();
string pk = Guid.NewGuid().ToString();
// Add insert
ComplexEntity sendEnt = new ComplexEntity();
sendEnt.PartitionKey = pk;
sendEnt.RowKey = Guid.NewGuid().ToString();
Dictionary<string, EntityProperty> properties = new Dictionary<string, EntityProperty>();
EntityProperty prop1 = properties["BoolN"] = EntityProperty.GeneratePropertyForBool(null);
sendEnt.BoolN = prop1.BooleanValue = true;
EntityProperty prop2 = properties["DoubleN"] = EntityProperty.GeneratePropertyForDouble(null);
sendEnt.DoubleN = prop2.DoubleValue = 3.1415;
EntityProperty prop3 = properties["GuidN"] = EntityProperty.GeneratePropertyForGuid(null);
sendEnt.GuidN = prop3.GuidValue = Guid.NewGuid();
EntityProperty prop4 = properties["Int32N"] = EntityProperty.GeneratePropertyForInt(null);
sendEnt.Int32N = prop4.Int32Value = 1;
EntityProperty prop5 = properties["Int64N"] = EntityProperty.GeneratePropertyForLong(null);
sendEnt.Int64N = prop5.Int64Value = 1234;
EntityProperty prop6 = properties["String"] = EntityProperty.GeneratePropertyForString(null);
sendEnt.String = prop6.StringValue = "hello";
EntityProperty prop7 = properties["DateTimeOffsetN"] = EntityProperty.GeneratePropertyForDateTimeOffset(null);
sendEnt.DateTimeOffsetN = prop7.DateTimeOffsetValue = DateTimeOffset.UtcNow;
ComplexEntity retrievedEntity = new ComplexEntity();
retrievedEntity.ReadEntity(properties, null);
Assert.AreEqual(sendEnt.BoolN, retrievedEntity.BoolN);
Assert.AreEqual(sendEnt.DoubleN, retrievedEntity.DoubleN);
Assert.AreEqual(sendEnt.GuidN, retrievedEntity.GuidN);
Assert.AreEqual(sendEnt.Int32N, retrievedEntity.Int32N);
Assert.AreEqual(sendEnt.Int64N, retrievedEntity.Int64N);
Assert.AreEqual(sendEnt.String, retrievedEntity.String);
Assert.AreEqual(sendEnt.DateTimeOffsetN, retrievedEntity.DateTimeOffsetN);
}
示例12: DoTableRetrieveWithGenericOverloadWithProjectionSync
private void DoTableRetrieveWithGenericOverloadWithProjectionSync(TablePayloadFormat format)
{
tableClient.DefaultRequestOptions.PayloadFormat = format;
// Insert entity
string pk = Guid.NewGuid().ToString();
string rk = Guid.NewGuid().ToString();
TableEntity.DisableCompiledSerializers = true;
ComplexEntity sendEnt = new ComplexEntity(pk, rk);
sendEnt.String = "ResetTestTotested";
sendEnt.Double = (Double)5678.5678;
sendEnt.IntegerPrimitive = 5678;
currentTable.Execute(TableOperation.Insert(sendEnt));
List<string> selectedColumns = new List<string>
{
"Double",
"IntegerPrimitive"
};
// Retrieve entity
TableResult result = currentTable.Execute(TableOperation.Retrieve<ComplexEntity>(sendEnt.PartitionKey, sendEnt.RowKey, selectedColumns));
ComplexEntity retEntity = result.Result as ComplexEntity;
// Validate entity
Assert.AreEqual(retEntity.Double, sendEnt.Double);
Assert.AreEqual(retEntity.IntegerPrimitive, sendEnt.IntegerPrimitive);
Assert.AreNotEqual(retEntity.String, sendEnt.String);
}
示例13: TableEdmTypeCheck
public void TableEdmTypeCheck()
{
CloudTableClient tableClient = GenerateCloudTableClient();
string pk = Guid.NewGuid().ToString();
DynamicTableEntity sendEnt = new DynamicTableEntity();
sendEnt.PartitionKey = pk;
sendEnt.RowKey = Guid.NewGuid().ToString();
ComplexEntity ent = new ComplexEntity();
ent.String = null;
sendEnt.Properties = ent.WriteEntity(null);
string value = sendEnt.Properties["String"].StringValue;
Assert.AreEqual(EdmType.String, sendEnt.Properties["String"].PropertyType);
sendEnt.Properties["String"].StringValue = "helloworld";
Assert.AreEqual(EdmType.String, sendEnt.Properties["String"].PropertyType);
sendEnt.Properties["String"].StringValue = null;
Assert.AreEqual(EdmType.String, sendEnt.Properties["String"].PropertyType);
ent.Binary = null;
sendEnt.Properties = ent.WriteEntity(null);
byte[] binaryValue = sendEnt.Properties["Binary"].BinaryValue;
Assert.AreEqual(EdmType.Binary, sendEnt.Properties["Binary"].PropertyType);
sendEnt.Properties["Binary"].BinaryValue = new byte[] { 1, 2 };
Assert.AreEqual(EdmType.Binary, sendEnt.Properties["Binary"].PropertyType);
sendEnt.Properties["Binary"].BinaryValue = null;
Assert.AreEqual(EdmType.Binary, sendEnt.Properties["Binary"].PropertyType);
ent.DateTimeN = null;
sendEnt.Properties = ent.WriteEntity(null);
DateTime? dateTimeValue = sendEnt.Properties["DateTimeN"].DateTime;
Assert.AreEqual(EdmType.DateTime, sendEnt.Properties["DateTimeN"].PropertyType);
sendEnt.Properties["DateTimeN"].DateTime = DateTime.Now;
Assert.AreEqual(EdmType.DateTime, sendEnt.Properties["DateTimeN"].PropertyType);
sendEnt.Properties["DateTimeN"].DateTime = null;
Assert.AreEqual(EdmType.DateTime, sendEnt.Properties["DateTimeN"].PropertyType);
ent.DateTimeOffsetN = null;
sendEnt.Properties = ent.WriteEntity(null);
DateTimeOffset? dateTimeOffsetValue = sendEnt.Properties["DateTimeOffsetN"].DateTimeOffsetValue;
Assert.AreEqual(EdmType.DateTime, sendEnt.Properties["DateTimeOffsetN"].PropertyType);
sendEnt.Properties["DateTimeOffsetN"].DateTimeOffsetValue = DateTimeOffset.Now;
Assert.AreEqual(EdmType.DateTime, sendEnt.Properties["DateTimeOffsetN"].PropertyType);
sendEnt.Properties["DateTimeOffsetN"].DateTimeOffsetValue = null;
Assert.AreEqual(EdmType.DateTime, sendEnt.Properties["DateTimeOffsetN"].PropertyType);
ent.DoubleN = null;
sendEnt.Properties = ent.WriteEntity(null);
double? doubleValue = sendEnt.Properties["DoubleN"].DoubleValue;
Assert.AreEqual(EdmType.Double, sendEnt.Properties["DoubleN"].PropertyType);
sendEnt.Properties["DoubleN"].DoubleValue = 1234.5678;
Assert.AreEqual(EdmType.Double, sendEnt.Properties["DoubleN"].PropertyType);
sendEnt.Properties["DoubleN"].DoubleValue = null;
Assert.AreEqual(EdmType.Double, sendEnt.Properties["DoubleN"].PropertyType);
ent.GuidN = null;
sendEnt.Properties = ent.WriteEntity(null);
Guid? guidValue = sendEnt.Properties["GuidN"].GuidValue;
Assert.AreEqual(EdmType.Guid, sendEnt.Properties["GuidN"].PropertyType);
sendEnt.Properties["GuidN"].GuidValue = Guid.NewGuid();
Assert.AreEqual(EdmType.Guid, sendEnt.Properties["GuidN"].PropertyType);
sendEnt.Properties["GuidN"].GuidValue = null;
Assert.AreEqual(EdmType.Guid, sendEnt.Properties["GuidN"].PropertyType);
ent.Int32N = null;
sendEnt.Properties = ent.WriteEntity(null);
int? intValue = sendEnt.Properties["Int32N"].Int32Value;
Assert.AreEqual(EdmType.Int32, sendEnt.Properties["Int32N"].PropertyType);
sendEnt.Properties["Int32N"].Int32Value = 123;
Assert.AreEqual(EdmType.Int32, sendEnt.Properties["Int32N"].PropertyType);
sendEnt.Properties["Int32N"].Int32Value = null;
Assert.AreEqual(EdmType.Int32, sendEnt.Properties["Int32N"].PropertyType);
ent.LongPrimitiveN = null;
sendEnt.Properties = ent.WriteEntity(null);
long? longValue = sendEnt.Properties["LongPrimitiveN"].Int64Value;
Assert.AreEqual(EdmType.Int64, sendEnt.Properties["LongPrimitiveN"].PropertyType);
//.........这里部分代码省略.........
示例14: ReflectionBasedSerializationTest
public void ReflectionBasedSerializationTest()
{
ComplexEntity ent = new ComplexEntity();
ComplexEntity secondEnt = new ComplexEntity();
secondEnt.ReadEntity(ent.WriteEntity(null), null);
ComplexEntity.AssertEquality(ent, secondEnt);
}
示例15: DoTableGenericQueryComplexWithoutPropertyResolverSync
private void DoTableGenericQueryComplexWithoutPropertyResolverSync(TablePayloadFormat format)
{
tableClient.DefaultRequestOptions.PayloadFormat = format;
CloudTable currentTestTable = tableClient.GetTableReference("tbl" + Guid.NewGuid().ToString("N"));
try
{
currentTestTable.CreateIfNotExists();
ComplexEntity ent = new ComplexEntity("tables_batch_1", Guid.NewGuid().ToString());
currentTestTable.Execute(TableOperation.Insert(ent));
TableQuery<ComplexEntity> query = new TableQuery<ComplexEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "tables_batch_1"));
TableQuerySegment<ComplexEntity> seg = currentTestTable.ExecuteQuerySegmented(query, null);
foreach (ComplexEntity retrievedEnt in seg)
{
Assert.AreEqual(retrievedEnt.PartitionKey, "tables_batch_1");
ComplexEntity.AssertEquality(ent, retrievedEnt);
}
}
finally
{
currentTestTable.DeleteIfExists();
}
}