当前位置: 首页>>代码示例>>C#>>正文


C# Table.DynamicTableEntity类代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity的典型用法代码示例。如果您正苦于以下问题:C# DynamicTableEntity类的具体用法?C# DynamicTableEntity怎么用?C# DynamicTableEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DynamicTableEntity类属于Microsoft.WindowsAzure.Storage.Table命名空间,在下文中一共展示了DynamicTableEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessEventsAsync

        public async Task ProcessEventsAsync(PartitionContext context, IEnumerable<EventData> messages)
        {
            var batch = new TableBatchOperation();

            foreach(var msg in messages)
            {
                var snap = JsonConvert.DeserializeObject<BusSnapshotInfo>(Encoding.UTF8.GetString(msg.GetBytes()));

                var entity = new DynamicTableEntity(snap.RouteShortName, snap.VehicleId.ToString());

                entity.Properties.Add("RouteShortName", EntityProperty.GeneratePropertyForString(snap.RouteShortName));
                entity.Properties.Add("VehicleId", EntityProperty.GeneratePropertyForInt(snap.VehicleId));
                entity.Properties.Add("TripId", EntityProperty.GeneratePropertyForInt(snap.TripId));
                entity.Properties.Add("Latitude", EntityProperty.GeneratePropertyForDouble(snap.Latitude));
                entity.Properties.Add("Longitude", EntityProperty.GeneratePropertyForDouble(snap.Longitude));
                entity.Properties.Add("DirectionOfTravel", EntityProperty.GeneratePropertyForString(snap.DirectionOfTravel.ToString()));
                entity.Properties.Add("NextStopId", EntityProperty.GeneratePropertyForInt(snap.NextStopId));
                entity.Properties.Add("Timeliness", EntityProperty.GeneratePropertyForString(snap.Timeliness.ToString()));
                entity.Properties.Add("TimelinessOffset", EntityProperty.GeneratePropertyForInt(snap.TimelinessOffset));
                entity.Properties.Add("Timestamp", EntityProperty.GeneratePropertyForDateTimeOffset(snap.Timestamp));

                batch.Add(TableOperation.InsertOrReplace(entity));
            }

            var tableClient = _account.CreateCloudTableClient();

            var table = tableClient.GetTableReference("snapshots");

            await table.CreateIfNotExistsAsync();

            await table.ExecuteBatchAsync(batch);

            await context.CheckpointAsync();
        }
开发者ID:jplane,项目名称:TheMartaBus.AzureServiceFabric,代码行数:34,代码来源:StorageProcessor.cs

示例2: ObjectToDynamicMeasurement

        public void ObjectToDynamicMeasurement()
        {
            // Arrange
            Country entity = ObjectsFactory.GetCountry();
            Stopwatch stopWatch = Stopwatch.StartNew();
            DynamicTableEntity dynamicTableEntity = null;

            // Act
            for (int i = 0; i < IteractionsCount; i++)
            {
                dynamicTableEntity = new DynamicTableEntity(entity.Continent, entity.Name)
                    {
                        Properties = new Dictionary<string, EntityProperty>
                            {
                                {"Area", new EntityProperty(entity.Area)},
                                {"TopSecretKey", new EntityProperty(entity.TopSecretKey)},
                                {"Formed", new EntityProperty(entity.Formed)},
                                {"Id", new EntityProperty(entity.Id)},
                                {"IsExists", new EntityProperty(entity.IsExists)},
                                {"Population", new EntityProperty(entity.Population)},
                                {"PresidentsCount", new EntityProperty(entity.PresidentsCount)}
                            }
                    };
            }

            stopWatch.Stop();

            Assert.NotNull(dynamicTableEntity);

            Console.WriteLine(ResultFormat, IteractionsCount, stopWatch.ElapsedMilliseconds);
        }
开发者ID:MarkDeVerno,项目名称:WindowsAzure,代码行数:31,代码来源:EntityConverterTests.cs

示例3: ToDte

        public static DynamicTableEntity ToDte(Post post)
        {
            var dte = new DynamicTableEntity(post.UniqueKey, string.Empty);

            dte.Properties.Add("Slug", EntityProperty.GeneratePropertyForString(post.Slug));
            dte.Properties.Add("Title", EntityProperty.GeneratePropertyForString(WebUtility.HtmlEncode(post.Title)));
            dte.Properties.Add("Date", EntityProperty.GeneratePropertyForDateTimeOffset(post.Date));
            dte.Properties.Add("DateModified", EntityProperty.GeneratePropertyForDateTimeOffset(post.DateModified));
            dte.Properties.Add("Categories", EntityProperty.GeneratePropertyForString(Category.ToString(post.Categories)));
            dte.Properties.Add("Tags", EntityProperty.GeneratePropertyForString(Category.ToString(post.Tags)));
            dte.Properties.Add("Author", EntityProperty.GeneratePropertyForString(PostAuthor.ToString(post.Author)));
            dte.Properties.Add("CommentCount", EntityProperty.GeneratePropertyForInt(post.CommentCount));

            if (post.DasBlogEntryId.HasValue)
            {
                dte.Properties.Add("DasBlogEntryId", EntityProperty.GeneratePropertyForGuid(post.DasBlogEntryId.Value));
            }

            if (!string.IsNullOrEmpty(post.DasBlogTitle))
            {
                dte.Properties.Add("DasBlogTitle", EntityProperty.GeneratePropertyForString(post.DasBlogTitle));
            }

            if (!string.IsNullOrEmpty(post.DasBlogUniqueTitle))
            {
                dte.Properties.Add("DasBlogUniqueTitle", EntityProperty.GeneratePropertyForString(post.DasBlogUniqueTitle));
            }

            return dte;
        }
开发者ID:robpaveza,项目名称:Hawk,代码行数:30,代码来源:Post.cs

示例4: NextId

		public async Task<long> NextId()
		{
			lock (nextLock)
			{
				if (last < max)
				{
					return ++last;
				}
			}
			await semaphore.WaitAsync();
			try
			{
				lock (nextLock)
				{
					if (last < max)
					{
						return ++last;
					}
				}
				for (var tries = 0; tries < 10; ++tries)
				{
					HttpStatusCode saveResultCode;
					long oldMax, newMax;
					var hiEntity = await HiloTable.RetreiveAsync(tableName, "hi");
					if (hiEntity == null)
					{
						oldMax = 0;
						newMax = chunkSize;
						hiEntity = new DynamicTableEntity(tableName, "hi");
						hiEntity["max"] = new EntityProperty(newMax);
						saveResultCode = await HiloTable.InsertAsync(hiEntity);
					}
					else
					{
						oldMax = hiEntity["max"].Int64Value.GetValueOrDefault(0);
						newMax = oldMax + chunkSize;
						hiEntity["max"] = new EntityProperty(newMax);
						saveResultCode = await HiloTable.ReplaceAsync(hiEntity);
					}
					if (saveResultCode == HttpStatusCode.Created || saveResultCode == HttpStatusCode.NoContent)
					{
						lock (nextLock)
						{
							last = oldMax;
							max = newMax;
							return ++last;
						}
					}
				}
				throw new Exception(
					string.Format(
						"Could not allocate id range for table '{0}' with chunkSize={1} due to high contention.\r\nConsider increasing the chunk size",
						tableName, chunkSize));
			}
			finally
			{
				semaphore.Release();
			}

		}
开发者ID:kenegozi,项目名称:deep-sky-blue,代码行数:60,代码来源:HiLoIdGenerator.cs

示例5: Insert

        public void Insert()
        {
            TableBatchOperation batchOperation = new TableBatchOperation();
            Hashtable bank = new Hashtable();

            for (int i = id; i < id + 100 && i < Program._DATA_TABLE.Rows.Count; i++)
            {
                if (!bank.ContainsKey(Program._DATA_TABLE.Rows[i]["ID"].ToString().Trim()))
                {
                    try
                    {
                        DynamicTableEntity data = new DynamicTableEntity();
                        data.PartitionKey = "88888888";
                        data.RowKey = Program._DATA_TABLE.Rows[i]["ID"].ToString().Trim().PadLeft(6, '0');
                        Dictionary<string, EntityProperty> properties = new Dictionary<string, EntityProperty>();

                        properties.Add("Bank", new EntityProperty(Program._DATA_TABLE.Rows[i]["Bank"].ToString().Trim()));
                        properties.Add("BranchName", new EntityProperty(Program._DATA_TABLE.Rows[i]["BranchName"].ToString().ToLower().Trim()));
                        properties.Add("AccountNumber", new EntityProperty(Program._DATA_TABLE.Rows[i]["AccountNumber"].ToString().Trim()));
                        properties.Add("AccountName", new EntityProperty(Program._DATA_TABLE.Rows[i]["AccountName"].ToString().Trim()));
                        properties.Add("AccountType", new EntityProperty(int.Parse(Program._DATA_TABLE.Rows[i]["AccountType"].ToString().Trim())));

                        //BankEntity data = new BankEntity("88888888", Program._DATA_TABLE.Rows[i]["ID"].ToString().Trim().PadLeft(6, '0'));
                        //data.Bank = Program._DATA_TABLE.Rows[i]["Bank"].ToString().Trim();
                        //data.BranchName = Program._DATA_TABLE.Rows[i]["BranchName"].ToString().ToLower().Trim();
                        //data.AccountNumber = Program._DATA_TABLE.Rows[i]["AccountNumber"].ToString().Trim();
                        //data.AccountName = Program._DATA_TABLE.Rows[i]["AccountName"].ToString().Trim();
                        //data.AccountType = int.Parse(Program._DATA_TABLE.Rows[i]["AccountType"].ToString().Trim());
                        batchOperation.InsertOrMerge(data);
                        recBank++;
                        bank[Program._DATA_TABLE.Rows[i]["ID"].ToString().Trim()] = true;
                    }
                    catch { }
                }
            }

            try
            {
                if (Program._DATA_TABLE.Rows.Count > 0)
                {
                    if (Program._UPDATE)
                    {
                        Program._RECORD++;
                        Console.WriteLine("Update Record {0}-{1}\t\tTotal {2} Records", id + 1, id + 100, Program._RECORD * 100);
                        Program._CLOUD_TABLE.ExecuteBatch(batchOperation);
                    }
                    else
                    {
                        Program._RECORD++;
                        Console.WriteLine("Insert Record {0}-{1}\t\tTotal {2} Records", id + 1, id + 100, Program._RECORD * 100);
                        Program._CLOUD_TABLE.ExecuteBatch(batchOperation);
                    }
                }

            }
            catch (Exception e)
            {
                Program.WriteErrorLog("Record " + (id + 1) + "-" + (id + 100) + " Error \n" + e.Message + "\n" + e.StackTrace);
            }
        }
开发者ID:PowerDD,项目名称:DataSync,代码行数:60,代码来源:Bank.cs

示例6: Entity

            public Entity(DynamicTableEntity entity)
            {
                var splitted = entity.RowKey.Split(new string[] { "-" }, StringSplitOptions.None);
                _PartitionKey = entity.PartitionKey;
                Timestamp = entity.Timestamp;
                TxId = uint256.Parse(splitted[0]);
                Type = GetType(splitted[1]);
                if(splitted.Length >= 3 && splitted[2] != string.Empty)
                    BlockId = uint256.Parse(splitted[2]);
                var bytes = Helper.GetEntityProperty(entity, "a");
                if(bytes != null && bytes.Length != 0)
                {
                    Transaction = new Transaction();
                    Transaction.ReadWrite(bytes);
                }
                bytes = Helper.GetEntityProperty(entity, "b");
                if(bytes != null && bytes.Length != 0)
                {
                    ColoredTransaction = new ColoredTransaction();
                    ColoredTransaction.ReadWrite(bytes);
                }
                _PreviousTxOuts = Helper.DeserializeList<TxOut>(Helper.GetEntityProperty(entity, "c"));

                var timestamp = Helper.GetEntityProperty(entity, "d");
                if(timestamp != null && timestamp.Length == 8)
                {
                    Timestamp = new DateTimeOffset((long)ToUInt64(timestamp, 0), TimeSpan.Zero);
                }
            }
开发者ID:bijakatlykkex,项目名称:NBitcoin.Indexer,代码行数:29,代码来源:TransactionEntry.cs

示例7: Create

        public static Action Create(this TransactionLog transactionLogMessage, string connectionString)
        {
            IAzureTableUtility azureTableUtility = ContextFactory.Create(connectionString, transactionLogMessage.TableName);

            JObject jsonMessage = JsonConvert.DeserializeObject<JObject>(transactionLogMessage.Object);

            DynamicTableEntity temp = new DynamicTableEntity();
            foreach (KeyValuePair<string, JToken> keyValuePair in jsonMessage)
            {
                if (keyValuePair.Key.Equals("Timestamp") || keyValuePair.Key.Equals("ETag"))
                    continue;
                
                if (keyValuePair.Key.Equals("PartitionKey"))
                    temp.PartitionKey = keyValuePair.Value.ToString();
                else if (keyValuePair.Key.Equals("RowKey"))
                    temp.RowKey = keyValuePair.Value.ToString();
                else
                    temp.Properties.Add(keyValuePair.Key, EntityProperty.CreateEntityPropertyFromObject(keyValuePair.Value));

            }

            string actionType = transactionLogMessage.Action;
            if (actionType.Equals("UPSERT", StringComparison.OrdinalIgnoreCase) || actionType.Equals("INSERT", StringComparison.OrdinalIgnoreCase))
                return () => azureTableUtility.Upset<DynamicTableEntity>(temp);
            if (actionType.Equals("DELETE", StringComparison.OrdinalIgnoreCase))
                return () => azureTableUtility.DeleteEntity(temp.PartitionKey, temp.RowKey);

            return default(Action);
        }
开发者ID:jsucupira,项目名称:table-storage-geo-redundancy,代码行数:29,代码来源:ReplicationStrategy.cs

示例8: DeleteApiDetails

 public bool DeleteApiDetails()
 {
     var entity = new DynamicTableEntity(ApiRegistrationTableEntity.GetPartitionKey(ApiRegistrationProviderType.Jasper),
                         ApiRegistrationTableEntity.GetRowKey(ApiRegistrationProviderType.Jasper));
     entity.ETag = "*";
     _table.Execute(TableOperation.Delete(entity));
     return true;
 }
开发者ID:rudibelt,项目名称:azure-iot-remote-monitoring,代码行数:8,代码来源:ApiRegistrationRepository.cs

示例9: PutVideo

        public int PutVideo(string video)
        {
            var entity = new DynamicTableEntity("VidParams", "LastVideo") { ETag = "*" };
            entity.Properties["VideoCode"] = new EntityProperty(video);
            _updateOperation = TableOperation.Replace(entity);

            dynamic result = _table.Execute(_updateOperation).Result;
            return result.Properties.Count;
        }
开发者ID:JuanKRuiz,项目名称:Noches-de-Innovacion-Website,代码行数:9,代码来源:NDIAzureTableController.cs

示例10: CopyEntity

 private void CopyEntity(DynamicTableEntity entity, CloudTable destTable)
 {
     ConsoleWrite.Verbose("    Copying {0} / {1}", entity.PartitionKey, entity.RowKey);
     if (_args.IsReal)
     {
         var operation = TableOperation.Insert(entity);
         destTable.Execute(operation);
     }
 }
开发者ID:colinangusmackay,项目名称:xander-azure-tools,代码行数:9,代码来源:CopyCommand.cs

示例11: GetSizeTest

		public void GetSizeTest()
		{
			var tableEntity = new DynamicTableEntity("TestPartitionKey", "TestRowKey");

			tableEntity.AddProperty("suppa", "duppa");

			tableEntity.AddProperty("suppa2", 10);

			var size = tableEntity.GetSize();
		}
开发者ID:stas-sultanov,项目名称:SXN.Azure,代码行数:10,代码来源:ITableEntityExtensionsTests.cs

示例12: CanSpreadBytes

        public void CanSpreadBytes()
        {
            var bytes =
                Helper.SerializeList(Enumerable.Range(0, 300000).Select(e => new OrderedBalanceChange.IntCompactVarInt((uint)e)).ToArray());

            DynamicTableEntity entity = new DynamicTableEntity();
            Helper.SetEntityProperty(entity, "a", bytes);
            var actualBytes = Helper.GetEntityProperty(entity, "a");
            Assert.True(actualBytes.SequenceEqual(bytes));
        }
开发者ID:bijakatlykkex,项目名称:NBitcoin.Indexer,代码行数:10,代码来源:TestClass.cs

示例13: Insert

        public void Insert()
        {
            TableBatchOperation batchOperation = new TableBatchOperation();
            Hashtable TransferD = new Hashtable();

            for (int i = id; i < id + 100 && i < Program._DATA_TABLE.Rows.Count; i++)
            {
                string Rowkey = (Program._DATA_TABLE.Rows[i]["ID"].ToString().Trim() + "-" + Program._DATA_TABLE.Rows[i]["SellNumber"].ToString().Trim());
                if (!TransferD.ContainsKey(Rowkey))
                {
                    try
                    {
                        DynamicTableEntity data = new DynamicTableEntity();
                        data.PartitionKey = "88888888";
                        data.RowKey = Rowkey;
                        Dictionary<string, EntityProperty> properties = new Dictionary<string, EntityProperty>();

                        properties.Add("SellNumber", new EntityProperty(Program._DATA_TABLE.Rows[i]["SellNumber"].ToString().Trim().PadLeft(8, '0')));
                        properties.Add("ReceiveMoney", new EntityProperty(double.Parse(Program._DATA_TABLE.Rows[i]["ReceiveMoney"].ToString().ToLower().Trim())));

                        //BankTransferDetailEntity data = new BankTransferDetailEntity("88888888", Rowkey);
                        //data.SellNumber = Program._DATA_TABLE.Rows[i]["SellNumber"].ToString().Trim().PadLeft(8, '0');
                        //data.ReceiveMoney = double.Parse(Program._DATA_TABLE.Rows[i]["ReceiveMoney"].ToString().ToLower().Trim());
                        batchOperation.InsertOrMerge(data);
                        recTransferD++;
                        TransferD[Rowkey] = true;
                    }
                    catch { }
                }
            }

            try
            {
                if (Program._DATA_TABLE.Rows.Count > 0)
                {
                    if (Program._UPDATE)
                    {
                        Program._RECORD++;
                        Console.WriteLine("Update Record {0}-{1}\t\tTotal {2} Records", id + 1, id + 100, Program._RECORD * 100);
                        Program._CLOUD_TABLE.ExecuteBatch(batchOperation);
                    }
                    else
                    {
                        Program._RECORD++;
                        Console.WriteLine("Insert Record {0}-{1}\t\tTotal {2} Records", id + 1, id + 100, Program._RECORD * 100);
                        Program._CLOUD_TABLE.ExecuteBatch(batchOperation);
                    }
                }

            }
            catch (Exception e)
            {
                Program.WriteErrorLog("Record " + (id + 1) + "-" + (id + 100) + " Error \n" + e.Message + "\n" + e.StackTrace);
            }
        }
开发者ID:PowerDD,项目名称:DataSync,代码行数:55,代码来源:BankTransferDetail.cs

示例14: ActionResult

        public void ActionResult(string id, IDictionary<string, string> result)
        {
            var resultEntity = new DynamicTableEntity(id, DateTime.UtcNow.ToString("s"));

            foreach (var resultProperty in result)
            {
                resultEntity.Properties[resultProperty.Key] = new EntityProperty(resultProperty.Value);
            }

            m_ResultTable.Execute(TableOperation.Insert(resultEntity));
        }
开发者ID:dlkj,项目名称:WorkerFramework,代码行数:11,代码来源:AzureTableStorage.cs

示例15: CanConvertFromSourceToSummary_WithAlternateTypeName

        public void CanConvertFromSourceToSummary_WithAlternateTypeName()
        {
            var entity = new DynamicTableEntity("pk", "rk");
            entity.Properties["dpi"] = EntityProperty.GeneratePropertyForInt(2);
            entity.Properties["AlternateTypeName"] = EntityProperty.GeneratePropertyForString("vahshi");
            var source = new DiagnosticsSource(entity);

            var summary = source.ToSummary();

            Assert.Equal(summary.TypeName, source.ToTypeKey());
        }
开发者ID:nicolagaletti,项目名称:ConveyorBelt,代码行数:11,代码来源:DiagnosticsSourceSummaryTests.cs


注:本文中的Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。