本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Table.TableQuery类的典型用法代码示例。如果您正苦于以下问题:C# TableQuery类的具体用法?C# TableQuery怎么用?C# TableQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TableQuery类属于Microsoft.WindowsAzure.Storage.Table命名空间,在下文中一共展示了TableQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: QueryTable
public IEnumerable<IDictionary<string, string>> QueryTable(string tableName, string oDataQuery)
{
if (string.IsNullOrWhiteSpace(tableName)) throw new ArgumentNullException("tableName");
Console.WriteLine(tableName);
var table = cloudTableClient.GetTableReference(tableName);
var query = new TableQuery();
if (!string.IsNullOrWhiteSpace(oDataQuery))
{
query.FilterString = oDataQuery;
}
foreach (var entity in table.ExecuteQuery(query))
{
var dictionary = new Dictionary<string, string>();
dictionary.Add("PartitionKey", entity.PartitionKey);
dictionary.Add("RowKey", entity.RowKey);
dictionary.Add("Timestamp", entity.Timestamp.ToString());
//dictionary.Add("Etag", entity.ETag);
foreach (var property in entity.Properties)
{
dictionary.Add(property.Key, property.Value.StringValue);
}
yield return dictionary;
}
}
开发者ID:RobBlackwell,项目名称:AzureCommandLineTools,代码行数:27,代码来源:TableHelper.cs
示例17: GetAuthors
public IEnumerable<Author> GetAuthors(string firstname, string lastname)
{
CloudTable authorTable = GetTableReference(tableName);
if (authorTable == null) return new List<Author>();
TableQuery<Author> query = default(TableQuery<Author>);
if (!string.IsNullOrEmpty(firstname) && !string.IsNullOrEmpty(lastname))
{
string lastnameFilter = TableQuery.GenerateFilterCondition("Lastname", QueryComparisons.Equal, lastname);
string firstnameFilter = TableQuery.GenerateFilterCondition("Firstname", QueryComparisons.Equal, firstname);
string finalFilter = TableQuery.CombineFilters(lastnameFilter, TableOperators.And, firstnameFilter);
query = new TableQuery<Author>().Where(finalFilter);
}
else if (!string.IsNullOrEmpty(firstname))
{
query = new TableQuery<Author>()
.Where(TableQuery.GenerateFilterCondition("Firstname", QueryComparisons.Equal, firstname));
}
else if (!string.IsNullOrEmpty(lastname))
{
query = new TableQuery<Author>()
.Where(TableQuery.GenerateFilterCondition("Lastname", QueryComparisons.Equal, lastname));
}
else
{
query = new TableQuery<Author>();
}
return authorTable.ExecuteQuery<Author>(query);
}
开发者ID:vishipayyallore,项目名称:SampleWebApplication,代码行数:32,代码来源:AuthorService.cs
示例18: ClearTable
public long ClearTable()
{
long deletionCount = 0;
// Construct the query operation for all customer entities where PartitionKey="Smith".
var list = new List<string>();
list.Add("PartitionKey");
list.Add("RowKey");
TableQuery<SensorValueEntity> query = new TableQuery<SensorValueEntity>().Select(list).Take(100);
var results = table.ExecuteQuery(query);
if (results.Count() < 1)
return deletionCount;
foreach(var resultGroup in results.GroupBy(a => a.PartitionKey))
{
TableBatchOperation batchOperation = new TableBatchOperation();
foreach (var result in resultGroup)
{
batchOperation.Delete(result);
deletionCount++;
}
table.ExecuteBatch(batchOperation);
}
return deletionCount;
}
开发者ID:thomasjetzinger,项目名称:smarthomecloud,代码行数:25,代码来源:SensorDataConnector.cs
示例19: FixtureForUpdatingBatchsOfRecords
public FixtureForUpdatingBatchsOfRecords()
{
// ARRANGE
TableClient = GetTableClient();
Table = CreateTable();
var tasks = Enumerable.Range(0, 600).Select(i =>
{
var op = TableOperation.Insert(new TestingEntity("partitionKey", Guid.NewGuid().ToString(), Guid.NewGuid().ToString()));
return Table.ExecuteAsync(op);
});
Task.WhenAll(tasks).Wait();
var tableQuery = new TableQuery<TestingEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "partitionKey"));
var subject = new TsSet<TestingEntity>(new TsTable<TestingEntity>(Table));
// ACT
Result = subject.BatchUpdateAsync(
tableQuery,
entities =>
{
entities.ForEach(e => e.MyProperty = "Test");
}).Result;
}
开发者ID:JoeStead,项目名称:Azure.Storage,代码行数:26,代码来源:FixtureForUpdatingBatchsOfRecords.cs
示例20: OpenAsync
public Task OpenAsync(PartitionContext context)
{
/*client = new HttpClient();
client.DefaultRequestHeaders.Add("X-ZUMO-APPLICATION", APP_KEY_MOBILE_SERVICES);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
return Task.FromResult<object>(null);*/
var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
var tableClient = storageAccount.CreateCloudTableClient();
sensorLogTable = tableClient.GetTableReference("SensorLog");
//sensorLogTable = tableClient.GetTableReference("SensorLog" + context.Lease.PartitionId);
// 閾値の取得
if (thresholdTempWarning == null)
{
var sensorConfigTable = tableClient.GetTableReference("SensorConfig");
var query = new TableQuery<SensorConfig>();
var configData = sensorConfigTable.ExecuteQuery(query);
foreach (SensorConfig config in configData)
{
if (config.PartitionKey == "TemperatureWarning")
{
thresholdTempWarning = config.Threshold;
System.Console.WriteLine("ThresholdTempWarning: " + thresholdTempWarning);
}
else if (config.PartitionKey == "TemperatureDanger")
{
thresholdTempDanger = config.Threshold;
System.Console.WriteLine("ThresholdTempDanger: " + thresholdTempDanger);
}
}
}
return sensorLogTable.CreateIfNotExistsAsync();
}
开发者ID:kenjihiranabe,项目名称:IoT-Hackathon-Zubogani-2015,代码行数:35,代码来源:SensorEventProcessor.cs
注:本文中的Microsoft.WindowsAzure.Storage.Table.TableQuery类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论