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


C# TableQuery.Select方法代码示例

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


在下文中一共展示了TableQuery.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetEventsCount

        //public static IEnumerable<WindowsAzureTableEventEntry> GetEvents(string connectionString, string tableName)
        //{
        //    var table = GetTable(connectionString, tableName);
        //    var query = new TableQuery<WindowsAzureTableEventEntry>();
        //    return table.ExecuteQuery<WindowsAzureTableEventEntry>(query).ToList();
        //}

        public static int GetEventsCount(string connectionString, string tableName)
        {
            var table = GetTable(connectionString, tableName);
            if (!table.Exists())
            {
                return 0;
            }

            var query = new TableQuery<WindowsAzureTableEventEntry>();
            return table.ExecuteQuery<WindowsAzureTableEventEntry>(query.Select(new List<string>() { "PartitionKey", "RowKey", "EventId" })).Count();
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:18,代码来源:AzureTableHelper.cs

示例2: GetTableData

        /// <summary>
        /// Gets all table record based on the table name form the azure table storage.
        /// </summary>
        /// <param name="tableName">azure table name</param>
        /// <param name="filter">filter</param>
        /// <param name="columns">column to select</param>
        /// <returns></returns>
        public IEnumerable<DynamicTableEntity> GetTableData(
            string tableName,
            string filter = "",
            IList<string> columns = null)
        {
            CloudTable table = getTable(tableName);
            TableQuery query = new TableQuery();

            if (filter != string.Empty)
                query.FilterString = filter;
            if (columns != null)
                query.Select(columns);

            return table.ExecuteQuery(query);
        }
开发者ID:jenish1993,项目名称:AzureStorageLayer,代码行数:22,代码来源:AzureTablesStorage.cs

示例3: TruncateDiagnostics

		public static void TruncateDiagnostics(CloudStorageAccount storageAccount,
			DateTime startDateTime, DateTime finishDateTime, Func<DateTime, DateTime> stepFunciton, TraceSource traceSource)
		{

			var itemsRemoved = 0;
			try
			{
				var cloudTable = storageAccount.CreateCloudTableClient().GetTableReference("WADLogsTable");

				var query = new TableQuery();
				var dt = startDateTime;
				var prevDay = dt.Day;
				var errorsCount = 0;
				while (true)
				{
				
					dt = stepFunciton(dt);
					if (dt>finishDateTime)
						break;
					if (prevDay!=dt.Day)
						traceSource.TraceEvent(TraceEventType.Error, 0, string.Format("PLEASE REMOVE TruncateDiagnostics day={0} , removed={1}", dt, itemsRemoved));
					prevDay = dt.Day;
					var l = dt.Ticks;
					var partitionKey =  "0" + l;
					query.FilterString = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.LessThan, partitionKey);
					query.Select(new string[] {});
					try
					{
						var items = cloudTable.ExecuteQuery(query).ToList();
						itemsRemoved += items.Count;
						const int chunkSize = 100;
						var chunkedList = new List<List<DynamicTableEntity>>();
						int index = 0;
						while (index < items.Count)
						{
							var count = items.Count - index > chunkSize ? chunkSize : items.Count - index;
							chunkedList.Add(items.GetRange(index, count));
							index += chunkSize;
						}
						foreach (var chunk in chunkedList)
						{
							var batches = new Dictionary<string, TableBatchOperation>();
							foreach (var entity in chunk)
							{
								var tableOperation = TableOperation.Delete(entity);
								if (batches.ContainsKey(entity.PartitionKey))
									batches[entity.PartitionKey].Add(tableOperation);
								else
									batches.Add(entity.PartitionKey, new TableBatchOperation { tableOperation });
							}

							foreach (var batch in batches.Values)
								cloudTable.ExecuteBatch(batch);
						}
						errorsCount = 0;
					}
					catch (Exception ex)
					{
						errorsCount++;
						traceSource.TraceEvent(TraceEventType.Error, 0, "ERROR ATTEMPT " + errorsCount+" "+ex);
						if (errorsCount > 10)
							throw;
						Thread.Sleep(60 * 100);
					}
					

				}


			}
			catch (Exception ex)
			{
				traceSource.TraceEvent(TraceEventType.Error, 0, ex.ToString());
				
			}
			if (itemsRemoved == 0)
				traceSource.TraceEvent(TraceEventType.Error, 0, "PLEASE REMOVE TruncateDiagnostics");
		}
开发者ID:Wdovin,项目名称:vc-community,代码行数:78,代码来源:AzureLogHelper.cs


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