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


C# Table.TableQuery类代码示例

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


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

示例1: GetAllCatalogJob

        public List<ICatalogJob> GetAllCatalogJob(string organization)
        {
            string tableName = NameHelper.GetCatalogJobTableName(organization);
            tableName = TableDataAccess.ValidateTableName(tableName);
            TableDataAccess tableDataAccess = new TableDataAccess(TableClient);
            CloudTable table = tableDataAccess.GetTable(tableName);
            if (table == null)
                return null;

            TableQuery<CatalogEntity> query = new TableQuery<CatalogEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, organization));

            query.TakeCount = 100;
            TableRequestOptions a = new TableRequestOptions();
            OperationContext c = new OperationContext();

            var queryResult = table.ExecuteQuery(query);

            List<ICatalogJob> result = new List<ICatalogJob>(queryResult.Count());
            foreach (CatalogEntity entity in queryResult)
            {
                CatalogEntity.SetOtherByPartitionRowKeys(entity);
                result.Add(entity);
            }
            return result;
        }
开发者ID:haiyangIt,项目名称:Haiyang,代码行数:25,代码来源:QueryDataAccess.cs

示例2: SendMessageTo

        private List<ConnectionEntity> SendMessageTo(String who, String message)
        {
            //var name = Context.User.Identity.Name;
            var name = this.GetConnectionUser();

            if (!String.IsNullOrEmpty(name))
            {
                var table = GetConnectionTable();

                // Notice that the partition keys are stored in azure storage as lower case
                var query = new TableQuery<ConnectionEntity>()
                    .Where(TableQuery.GenerateFilterCondition(
                    "PartitionKey",
                    QueryComparisons.Equal,
                    who.ToLowerInvariant()));

                var queryResult = table.ExecuteQuery(query).ToList();
                if (queryResult.Count == 0)
                {
                    Clients.Caller.showErrorMessage("The user is no longer connected.");
                }
                else
                {
                    // Load only once the host application connections to display the data there
                    if(queryResult.Count(o=>o.PartitionKey.Equals(Constants.SignalR_HostApplicationUserName.ToLowerInvariant())) <= 0)
                        queryResult.AddRange(this.SendMessageTo(Constants.SignalR_HostApplicationUserName, message));

                    return queryResult;
                }
            }

            return new List<ConnectionEntity>();
        }
开发者ID:hguomin,项目名称:MyFitnessTracker,代码行数:33,代码来源:ChatHub.cs

示例3: GetAllItemsFromParttion

        internal ISet<string> GetAllItemsFromParttion(string partitionKey)
        {
            var returnSet = new HashSet<string>();

            try
            {
                var tableQuery =
                    new TableQuery<ToBeIndexedEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey",
                                                                                                 QueryComparisons.Equal,
                                                                                                 partitionKey));
                var exec = _table.ExecuteQuery(tableQuery);

                foreach (var toBeIndexedEntity in exec)
                {
                    returnSet.Add(toBeIndexedEntity.EntityId);
                }

            }
            catch (Exception ex)
            {
                Trace.TraceError("Error in getting all entities for parition {0}, exception {1}", partitionKey, ex);
            }

            return returnSet;
        }
开发者ID:viren85,项目名称:moviemirchi,代码行数:25,代码来源:ToBeIndexedTable.cs

示例4: TableBinding

        public TableBinding(ScriptHostConfiguration config, TableBindingMetadata metadata, FileAccess access) 
            : base(config, metadata, access)
        {
            if (string.IsNullOrEmpty(metadata.TableName))
            {
                throw new ArgumentException("The table name cannot be null or empty.");
            }

            TableName = metadata.TableName;

            PartitionKey = metadata.PartitionKey;
            if (!string.IsNullOrEmpty(PartitionKey))
            {
                _partitionKeyBindingTemplate = BindingTemplate.FromString(PartitionKey);
            }

            RowKey = metadata.RowKey;
            if (!string.IsNullOrEmpty(RowKey))
            {
                _rowKeyBindingTemplate = BindingTemplate.FromString(RowKey);
            }

            _tableQuery = new TableQuery
            {
                TakeCount = metadata.Take ?? 50,
                FilterString = metadata.Filter
            };
        }
开发者ID:isaacabraham,项目名称:azure-webjobs-sdk-script,代码行数:28,代码来源:TableBinding.cs

示例5: GetByIdAsync

        public async Task<Response<JsonObject>> GetByIdAsync(string id)
        {
            if (string.IsNullOrEmpty(id))
                throw new ArgumentNullException("id");

            var table = await DefineTableAsync(CreateCloudTable).ConfigureAwait(false);

            var query =
                new TableQuery<DynamicTableEntity>();
            query.Where(TableQuery.CombineFilters(
                TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "PK"),
                TableOperators.And,
                TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, id)));
            query.Where(TableQuery.GenerateFilterConditionForBool("sys_deleted", "ne", true));

            var items = table.ExecuteQuery(query);
            var result = items.ToList();
            var json = new JsonObject();
            var status = HttpStatusCode.NotFound;

            // ReSharper disable UseMethodAny.3
            if (result.Count() <= 0) return new Response<JsonObject>(status, json);
            // ReSharper restore UseMethodAny.3
            json = result.First().ToJsonObject();
            status = HttpStatusCode.OK;

            return new Response<JsonObject>(status, json);
        }
开发者ID:proactima,项目名称:DynamicFluentAzure,代码行数:28,代码来源:FluentAzure.cs

示例6: GetByCategoryId

        public List<Good> GetByCategoryId(string categoryId,
			bool? isApprover = null)
        {
            string filter;
            if (isApprover.HasValue)
            {
                filter = TableQuery.CombineFilters(
                    TableQuery.GenerateFilterCondition(
                        "PartitionKey",
                        QueryComparisons.Equal,
                        categoryId),
                    TableOperators.And,
                    TableQuery.GenerateFilterConditionForBool(
                        "IsApproved",
                        QueryComparisons.Equal,
                        isApprover.Value)
                    );
            }
            else
            {
                filter = TableQuery.GenerateFilterCondition(
                    "PartitionKey",
                    QueryComparisons.Equal,
                    categoryId);
            }

            var query = new TableQuery<Good>()
                .Where(filter);
            return Table.ExecuteQuery(query).ToList()
                .OrderBy(i => i.Title).ToList();
        }
开发者ID:TeamSpark-Learning,项目名称:Storage-NET-01,代码行数:31,代码来源:GoodService.cs

示例7: DeleteConfirmed

 public ActionResult DeleteConfirmed(string partitionKey)
 {
     // Delete all rows for this mailing list, that is,
     // Subscriber rows as well as MailingList rows.
     // Therefore, no need to specify row key.
     var query = new TableQuery<MailingList>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, partitionKey));
     var listRows = mailingListTable.ExecuteQuery(query).ToList();
     var batchOperation = new TableBatchOperation();
     int itemsInBatch = 0;
     foreach (MailingList listRow in listRows)
     {
         batchOperation.Delete(listRow);
         itemsInBatch++;
         if (itemsInBatch == 100)
         {
             mailingListTable.ExecuteBatch(batchOperation);
             itemsInBatch = 0;
             batchOperation = new TableBatchOperation();
         }
     }
     if (itemsInBatch > 0)
     {
         mailingListTable.ExecuteBatch(batchOperation);
     }
     return RedirectToAction("Index");
 }
开发者ID:phongha,项目名称:myprojects,代码行数:26,代码来源:MailingListController.cs

示例8: GetAllKeys

        public IEnumerable<SymmetricKey> GetAllKeys()
        {
            // Create the CloudTable object that represents the "people" table.
            var table = tableClient.GetTableReference(keyTableName);

            // Create a retrieve operation that takes a customer entity.
            var query = new TableQuery<SymmetricKey>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "SymmetricKey"));

            try
            {
                return table.ExecuteQuery(query).ToList();
            }
            catch (DataServiceQueryException dsq)
            {
                throw new AzureCryptoException("Failed to load encryption keys from storage", dsq);
            }
            catch (DataServiceClientException dsce)
            {
                throw new AzureCryptoException("Failed to load encryption keys from storage", dsce);
            }
            catch (Exception ex)
            {
                throw new AzureCryptoException("Could not load encryption keys table", ex);
            }
        }
开发者ID:VijitJain,项目名称:Azure.Security,代码行数:25,代码来源:SymmetricKeyTableManager.cs

示例9: Index

        public ActionResult Index(string id, string listName)
        {
            if (string.IsNullOrEmpty(id) == true || string.IsNullOrEmpty(listName))
            {
                ViewBag.errorMessage = "Empty subscriber ID or list name.";
                return View("Error");
            }
            string filter = TableQuery.CombineFilters(
                TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, listName),
                TableOperators.And,
                TableQuery.GenerateFilterCondition("SubscriberGUID", QueryComparisons.Equal, id));
            var query = new TableQuery<Subscriber>().Where(filter);
            var subscriber = mailingListTable.ExecuteQuery(query).ToList().Single();

            if (subscriber == null)
            {
                ViewBag.Message = "You are already unsubscribed";
                return View("Message");
            }

            var unsubscribeVM = new UnsubscribeVM();
            unsubscribeVM.EmailAddress = MaskEmail(subscriber.EmailAddress);
            unsubscribeVM.ListDescription = FindRow(subscriber.ListName, "mailinglist").Description;
            unsubscribeVM.SubscriberGUID = id;
            unsubscribeVM.Confirmed = null;
            return View(unsubscribeVM);
        }
开发者ID:phongha,项目名称:myprojects,代码行数:27,代码来源:UnsubscribeController.cs

示例10: GetLogEntities

 private List<LogEntity> GetLogEntities()
 {
     // Construct the query operation for all customer entities where PartitionKey="Smith".
     var query = new TableQuery<LogEntity>();
     var entities = _cloudTable.ExecuteQuery(query);
     return entities.ToList();
 }
开发者ID:abkonsta,项目名称:NLog.Extensions.AzureTableStorage,代码行数:7,代码来源:AzureTableStoragePerformanceTests.cs

示例11: PartitionScanAsync

        /// <summary>
        /// Demonstrate a partition scan whereby we are searching for all the entities within a partition. Note this is not as efficient 
        /// as a range scan - but definitely more efficient than a full table scan. The async API's require the user to implement 
        /// paging themselves using continuation tokens. 
        /// </summary>
        /// <param name="partitionKey">The partition within which to search</param>
        public static async Task<List<AuditModel>> PartitionScanAsync(string partitionKey)
        {
            // Retrieve the storage account from the connection string.
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                ConfigurationManager.AppSettings["StorageConnectionString"]);
            // Create the table client.
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            // Create the CloudTable object that represents the "people" table.
            CloudTable table = tableClient.GetTableReference("audit");

            TableQuery<AuditModel> partitionScanQuery = new TableQuery<AuditModel>().Where
                (TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, partitionKey));
            var toReturn = new List<AuditModel>();
            TableContinuationToken token = null;
            // Page through the results
            do
            {
                TableQuerySegment<AuditModel> segment = await table.ExecuteQuerySegmentedAsync(partitionScanQuery, token);
                token = segment.ContinuationToken;
                foreach (AuditModel entity in segment)
                {
                    toReturn.Add(entity);
                }
            }
            while (token != null);

            return toReturn.OrderByDescending(a=> a.Timestamp).ToList();
        }
开发者ID:Alaabahr,项目名称:estimation-score-sheet,代码行数:35,代码来源:AuditHelper.cs

示例12: GetReplyNotif

        public List<Reply> GetReplyNotif(string userid)
        {
            TableQuery<ReplyNotificationEntifity> query = new TableQuery<ReplyNotificationEntifity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, userid));

            List<Reply> replies = new List<Reply>();
            TableBatchOperation batchOperation = new TableBatchOperation();
            int count = 0;

            // Print the fields for each customer.
            foreach (ReplyNotificationEntifity entity in _replyNotification.ExecuteQuery(query))
            {
                replies.Add(JsonConvert.DeserializeObject<Reply>(entity.Content));

                batchOperation.Add(TableOperation.Delete(entity));
                count++;

                if((count % 100) == 0){
                    _replyNotification.ExecuteBatch(batchOperation);
                    batchOperation = new TableBatchOperation();
                    count = 0;
                }
            }

            if (count > 0)
            {
                _replyNotification.ExecuteBatch(batchOperation);
            }

            return replies;
        }
开发者ID:ptolemy,项目名称:MSGorilla,代码行数:30,代码来源:ReplyManager.cs

示例13: Get

        /*
        public IEnumerable<SensorLog> Get(string device_id)
        {
            var queryPairs = this.Request.GetQueryNameValuePairs();
            string dateLong = queryPairs.FirstOrDefault(q => q.Key == "date").Value;

            string storeCS = CloudConfigurationManager.GetSetting("StorageConnectionString");
            CloudStorageAccount storageAccound = CloudStorageAccount.Parse(storeCS);
            CloudTableClient tableClient = storageAccound.CreateCloudTableClient();
            CloudTable sensorLogTable = tableClient.GetTableReference("SensorLog");

            TableQuery<SensorLog> query = null;
            if (dateLong == null)
            {
                query = new TableQuery<SensorLog>().Where(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, device_id));
            } else
            {
                long dateBinary = long.Parse(dateLong);
                DateTime data = DateTime.FromBinary(dateBinary);
                query = new TableQuery<SensorLog>().Where(
                    TableQuery.CombineFilters(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, device_id),
                    TableOperators.And,
                    TableQuery.GenerateFilterConditionForDate("UploadTime", QueryComparisons.GreaterThan, data)));
            }
            var results = sensorLogTable.ExecuteQuery(query);
            var sorted = from t in results orderby t.UploadTime select t;
            return sorted.Select(ent => (SensorLog)ent).ToList();
        }*/
        public IEnumerable<SensorLog> Get(string device_id, int len)
        {
            var queryPairs = this.Request.GetQueryNameValuePairs();
            string dateLong = queryPairs.FirstOrDefault(q => q.Key == "date").Value;

            string storeCS = CloudConfigurationManager.GetSetting("StorageConnectionString");
            CloudStorageAccount storageAccound = CloudStorageAccount.Parse(storeCS);
            CloudTableClient tableClient = storageAccound.CreateCloudTableClient();
            tableClient.DefaultRequestOptions = new TableRequestOptions()
            {
                PayloadFormat = TablePayloadFormat.JsonNoMetadata
            };
            CloudTable sensorLogTable = tableClient.GetTableReference("SensorLog");

            TableQuery<SensorLog> query = null;
            if (dateLong == null)
            {
                query = new TableQuery<SensorLog>().Where(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, device_id));
            }
            else
            {
                long dateBinary = long.Parse(dateLong);
                DateTime data = DateTime.FromBinary(dateBinary);
                query = new TableQuery<SensorLog>().Where(
                    TableQuery.CombineFilters(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, device_id),
                    TableOperators.And,
                    TableQuery.GenerateFilterConditionForDate("UploadTime", QueryComparisons.GreaterThan, data)));
            }
            var results = sensorLogTable.ExecuteQuery(query);
            var sorted = from t in results orderby t.UploadTime select t;
            var list = sorted.Select(ent => (SensorLog)ent).ToList();
            return list.GetRange(list.Count - len, len);
        }
开发者ID:kenjihiranabe,项目名称:IoT-Hackathon-Zubogani-2015,代码行数:65,代码来源:SensorController.cs

示例14: MapQuery

    private TableQuery<LogEntity> MapQuery(AzureNLogQueryDefinition originalQuery)
    {
      var query = new TableQuery<LogEntity>();
      var filters = new[]
      {
        this.GetPartitionKeyFilter(originalQuery), this.GetMinDateFilter(originalQuery),
        this.GetMaxDateFilter(originalQuery), this.GetLevelFilter(originalQuery)
      }
        .Where(f => !string.IsNullOrWhiteSpace(f))
        .ToArray();

      if (!filters.Any())
      {
        return query;
      }

      var querySt = filters[0];

      for (var i = 1; i < filters.Length; i++)
      {
        querySt = TableQuery.CombineFilters(querySt, TableOperators.And, filters[i]);
      }

      return query.Where(querySt);
    }
开发者ID:caseyjmorris,项目名称:NLogAzureTableStorageViewer,代码行数:25,代码来源:TableQueryer.cs

示例15: Index

        //
        // GET: /Subscription/
        //
        // Note: This way of handling may not scale and may need to use continuation tokens later
        //
        public ActionResult Index()
        {
            TableRequestOptions reqOptions = new TableRequestOptions()
            {
                MaximumExecutionTime = TimeSpan.FromSeconds(10),
                RetryPolicy = new LinearRetry(TimeSpan.FromSeconds(3), 3)
            };

            List<Subscription> subscribers;
            try
            {
                var query = new TableQuery<Subscription>().Select(new string[] {
                    "PartitionKey",
                    "RowKey",
                    "Description",
                    "Verified"
                });

                subscribers = subscribersTable.ExecuteQuery(query, reqOptions).ToList();
            }
            catch (StorageException se)
            {
                ViewBag.errorMessage = "Timeout error, try again.";
                Trace.TraceError(se.Message);
                return View("Error: " + se.Message);
            }

            return View(subscribers);
        }
开发者ID:bwrichte,项目名称:LoggingService,代码行数:34,代码来源:SubscriptionController.cs


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