本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Table.TableQuery.Where方法的典型用法代码示例。如果您正苦于以下问题:C# TableQuery.Where方法的具体用法?C# TableQuery.Where怎么用?C# TableQuery.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Table.TableQuery
的用法示例。
在下文中一共展示了TableQuery.Where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: GetAllTags
public IEnumerable<string> GetAllTags(string feed)
{
var query = new TableQuery<FeedEntryEntity>();
query.Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, feed));
var retrievedResults = Table.ExecuteQuery(query);
return retrievedResults.Where(x => x.Tag != null).Select(x => x.Tag).Distinct();
}
示例4: GetFeeds
public IEnumerable<FeedMetaData> GetFeeds(string username)
{
var query = new TableQuery<FeedMetaData>();
query.Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, username));
var retrievedResults = Table.ExecuteQuery(query);
return retrievedResults;
}
示例5: GetPublishFeedEntries
public IEnumerable<FeedEntryEntity> GetPublishFeedEntries(string feed)
{
var query = new TableQuery<FeedEntryEntity>();
query.Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, feed));
var retrievedResults = Table.ExecuteQuery(query);
return retrievedResults.Where(x => x.PublishedAt <= DateTime.Now).OrderByDescending(x => x.PublishedAt);
}
示例6: GetAllWithTag
public IEnumerable<FeedEntryEntity> GetAllWithTag(string feedName, string selectedtag)
{
var query = new TableQuery<FeedEntryEntity>();
var generateFilterCondition = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, feedName);
query.Where(generateFilterCondition);
var retrievedResults = Table.ExecuteQuery(query);
var result = retrievedResults.Where(x => x.Tag == selectedtag)
.ToList();
return result;
}
示例7: Query
/// <summary>
/// Query Table Storage
/// </summary>
/// <param name="identifier">Identifier</param>
/// <param name="version">Version</param>
/// <param name="fileName">File Name</param>
/// <returns></returns>
public virtual async Task<IEnumerable<IDictionary<string, object>>> Query(Guid? identifier = null, string version = null, string fileName = null)
{
var partitionFilter = identifier.HasValue ? TableQuery.GenerateFilterCondition(TableStorage.PartitionKey, QueryComparisons.Equal, identifier.Value.ToString()) : null;
var rowFilter = !string.IsNullOrWhiteSpace(version) ? TableQuery.GenerateFilterCondition(TableStorage.RowKey, QueryComparisons.Equal, version) : null;
var query = new TableQuery();
if (null != partitionFilter && null != rowFilter)
{
query.Where(TableQuery.CombineFilters(partitionFilter, TableOperators.And, rowFilter));
}
else if (null != partitionFilter)
{
query.Where(partitionFilter);
}
else if (null != rowFilter)
{
query.Where(rowFilter);
}
var images = await this.table.Query(query);
if (null != images)
{
images = images.Where(i => string.IsNullOrWhiteSpace(fileName) || fileName == (string)i["FileName"]);
foreach (var data in images)
{
data.Add("Identifier", data[TableStorage.PartitionKey]);
data.Add("Version", data[TableStorage.RowKey]);
data.Add("CreatedOn", data[TableStorage.Timestamp]);
data.Remove(TableStorage.PartitionKey);
data.Remove(TableStorage.Timestamp);
data.Remove(TableStorage.RowKey);
data.Remove(TableStorage.ETag);
}
}
return images;
}
示例8: GetAllLinks
public IEnumerable<string> GetAllLinks(string feedName)
{
var query = new TableQuery<FeedEntryEntity>();
var generateFilterCondition = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, feedName);
query.Where(generateFilterCondition);
var retrievedResults = Table.ExecuteQuery(query);
var result = retrievedResults
.Where(x => x.Link != null)
.Select(x => x.Link)
.ToList();
return result;
}
示例9: Query
// NOTE: we don't have a need (yet?) to query commands, as we don't use them to
// recreate read models, nor we are using it for BI, so we just
// expose events.
public IEnumerable<IEvent> Query(QueryCriteria criteria)
{
var context = this.tableClient;
var query = new TableQuery<MessageLogEntity>()
.Where(x => x.Kind == StandardMetadata.EventKind);
var where = criteria.ToExpression();
if (where != null)
{
query = query.Where(where);
}
var table = context.GetTableReference(this.tableName);
return table.ExecuteQuery(query.AsTableQuery())
.ToList()
.Select(e => this.serializer.Deserialize<IEvent>(e.Payload));
}
示例10: GetData
private async Task<TableQuerySegment<DynamicTableEntity>> GetData(string tableName, string filter, TableContinuationToken continuationToken)
{
var table = tableClient.GetTableReference(tableName);
if (!table.Exists())
{
throw new ArgumentException("Table does not exist", tableName);
}
var query = new TableQuery<DynamicTableEntity>();
if (!String.IsNullOrEmpty(filter))
{
query = query.Where(filter);
}
if (continuationToken != null)
{
continuationToken.NextTableName = tableName;
}
return await table.ExecuteQuerySegmentedAsync(query, continuationToken);
}
示例11: SearchCheeseReviewsAsync
public async Task<List<CheeseReviewEntity>> SearchCheeseReviewsAsync (string emailAddress)
{
List<CheeseReviewEntity> results = new List<CheeseReviewEntity> ();
try {
if (client == null)
await InitializeCloudClientAsync ();
var table = client.GetTableReference (reviewTable);
// Generate a query
var query = new TableQuery<CheeseReviewEntity> ();
// Looking for an exact match
query.Where (TableQuery.GenerateFilterCondition ("PartitionKey", QueryComparisons.Equal, emailAddress));
// This version of the Table Storage NuGet only has the option
// of returning a subset of the entire entity set at a time.
// We could use the TableContinuation token along with a loop to get
// everything out - but we'll just go with the first return
TableContinuationToken continueToken = null;
// Execute the query
var s = await table.ExecuteQuerySegmentedAsync (query, continueToken);
continueToken = s.ContinuationToken;
var searchResults = s.Results;
results.AddRange (s.Results);
} catch (Exception ex) {
var exMsg = ex.ToString ();
}
return results;
}
示例12: QueryTriples
private IEnumerable<Triple> QueryTriples(string dimension, string pk1)
{
var query = new TableQuery<GraphEntity>();
query.Where(string.Format("PartitionKey gt '{1}~{0}~' and PartitionKey lt '{1}~{0}~~'", KeyEncoder(pk1), dimension));
return table.ExecuteQuery(query).Select(entity => entity.ToTriple());
}
示例13: GenerateListTablesQuery
private TableQuery GenerateListTablesQuery(string prefix, int? maxResults)
{
TableQuery query = new TableQuery();
if (!string.IsNullOrEmpty(prefix))
{
// Append Max char to end '{' is 1 + 'z' in AsciiTable
string uppperBound = prefix + '{';
query = query.Where(TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition(TableConstants.TableName, QueryComparisons.GreaterThanOrEqual, prefix),
TableOperators.And,
TableQuery.GenerateFilterCondition(TableConstants.TableName, QueryComparisons.LessThan, uppperBound)));
}
if (maxResults.HasValue)
{
query = query.Take(maxResults.Value);
}
return query;
}
示例14: AppendLogs
private bool AppendLogs(CloudStorageAccount storageAccount, string partition, List<QLog> result, QLogBrowserSettings settings)
{
string[] partitionSplit = partition.Split(',');
string tableName = partitionSplit[0];
string tablePartition = partitionSplit[1];
string postfix = StorageConnectionHelper.GetPostfix(settings);
if(!String.IsNullOrWhiteSpace(postfix))
tableName = String.Format("qlog{0}{1}", postfix, tableName);
else
tableName = String.Format("qlog{0}", tableName);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference(tableName);
if (table.Exists())
{
TableQuery<QLog> logsQuery = new TableQuery<QLog>();
string filter = GetFilters(tablePartition, settings);
logsQuery.Where(filter);
foreach (QLog log in table.ExecuteQuery(logsQuery))
{
if (!String.IsNullOrWhiteSpace(settings.ContainingText))
if(!log.Message.ToLower().Contains(settings.ContainingText.ToLower()))
continue;
log.CreatedOn = log.CreatedOn.ToLocalTime();
result.Add(log);
if (result.Count >= settings.Limit)
return false;
}
return true;
}
else
return true;
}
示例15: DoEscapeTest
private void DoEscapeTest(string data, bool useBatch, bool includeKey)
{
DynamicTableEntity ent = new DynamicTableEntity(includeKey ? "temp" + data : "temp", Guid.NewGuid().ToString());
ent.Properties.Add("foo", new EntityProperty(data));
// Insert
if (useBatch)
{
TableBatchOperation batch = new TableBatchOperation();
batch.Insert(ent);
currentTable.ExecuteBatch(batch);
}
else
{
currentTable.Execute(TableOperation.Insert(ent));
}
// Retrieve
TableResult res = null;
if (useBatch)
{
TableBatchOperation batch = new TableBatchOperation();
batch.Retrieve(ent.PartitionKey, ent.RowKey);
res = (currentTable.ExecuteBatch(batch))[0];
}
else
{
res = currentTable.Execute(TableOperation.Retrieve(ent.PartitionKey, ent.RowKey));
}
// Check equality
DynamicTableEntity retrievedEntity = res.Result as DynamicTableEntity;
Assert.IsNotNull(retrievedEntity);
Assert.AreEqual(ent.PartitionKey, retrievedEntity.PartitionKey);
Assert.AreEqual(ent.RowKey, retrievedEntity.RowKey);
Assert.AreEqual(ent.ETag, retrievedEntity.ETag);
Assert.AreEqual(ent.Properties.Count, retrievedEntity.Properties.Count);
Assert.AreEqual(ent.Properties["foo"], retrievedEntity.Properties["foo"]);
// Query using data filter
TableQuery query = new TableQuery();
query.Where(string.Format(
"(PartitionKey eq \'{0}\') and (RowKey eq \'{1}\') and (foo eq \'{2}\')",
ent.PartitionKey,
ent.RowKey,
data.Replace("\'", "\'\'")));
retrievedEntity = currentTable.ExecuteQuery(query).Single();
Assert.IsNotNull(retrievedEntity);
Assert.AreEqual(ent.PartitionKey, retrievedEntity.PartitionKey);
Assert.AreEqual(ent.RowKey, retrievedEntity.RowKey);
Assert.AreEqual(ent.ETag, retrievedEntity.ETag);
Assert.AreEqual(ent.Properties.Count, retrievedEntity.Properties.Count);
Assert.AreEqual(ent.Properties["foo"], retrievedEntity.Properties["foo"]);
// Merge
ent.Properties.Add("foo2", new EntityProperty("bar2"));
if (useBatch)
{
TableBatchOperation batch = new TableBatchOperation();
batch.Merge(ent);
currentTable.ExecuteBatch(batch);
}
else
{
currentTable.Execute(TableOperation.Merge(ent));
}
// Retrieve
if (useBatch)
{
TableBatchOperation batch = new TableBatchOperation();
batch.Retrieve(ent.PartitionKey, ent.RowKey);
res = (currentTable.ExecuteBatch(batch))[0];
}
else
{
res = currentTable.Execute(TableOperation.Retrieve(ent.PartitionKey, ent.RowKey));
}
retrievedEntity = res.Result as DynamicTableEntity;
Assert.AreEqual(ent.PartitionKey, retrievedEntity.PartitionKey);
Assert.AreEqual(ent.RowKey, retrievedEntity.RowKey);
Assert.AreEqual(ent.ETag, retrievedEntity.ETag);
Assert.AreEqual(ent.Properties.Count, retrievedEntity.Properties.Count);
Assert.AreEqual(ent.Properties["foo"], retrievedEntity.Properties["foo"]);
// Replace
ent.Properties.Remove("foo2");
ent.Properties.Add("foo3", new EntityProperty("bar3"));
if (useBatch)
{
TableBatchOperation batch = new TableBatchOperation();
batch.Replace(ent);
currentTable.ExecuteBatch(batch);
}
else
//.........这里部分代码省略.........