本文整理汇总了C#中ICache.Query方法的典型用法代码示例。如果您正苦于以下问题:C# ICache.Query方法的具体用法?C# ICache.Query怎么用?C# ICache.Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICache
的用法示例。
在下文中一共展示了ICache.Query方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FullTextQueryExample
/// <summary>
/// Queries employees that live in Texas using full-text query API.
/// </summary>
/// <param name="cache">Cache.</param>
private static void FullTextQueryExample(ICache<int, Employee> cache)
{
var qry = cache.Query(new TextQuery("Employee", "TX"));
Console.WriteLine();
Console.WriteLine(">>> Employees living in Texas:");
foreach (var entry in qry)
Console.WriteLine(">>> " + entry.Value);
}
示例2: SqlQueryExample
/// <summary>
/// Queries employees that have provided ZIP code in address.
/// </summary>
/// <param name="cache">Cache.</param>
private static void SqlQueryExample(ICache<int, Employee> cache)
{
const int zip = 94109;
var qry = cache.Query(new SqlQuery(typeof(Employee), "zip = ?", zip));
Console.WriteLine();
Console.WriteLine(">>> Employees with zipcode {0} (SQL):", zip);
foreach (var entry in qry)
Console.WriteLine(">>> " + entry.Value);
}
示例3: SqlDistributedJoinQueryExample
/// <summary>
/// Queries employees that work for organization with provided name.
/// </summary>
/// <param name="cache">Cache.</param>
private static void SqlDistributedJoinQueryExample(ICache<int, Employee> cache)
{
const string orgName = "Apache";
var qry = cache.Query(new SqlQuery("Employee",
"from Employee, \"dotnet_cache_query_organization\".Organization " +
"where Employee.organizationId = Organization._key and Organization.name = ?", orgName)
{
EnableDistributedJoins = true
});
Console.WriteLine();
Console.WriteLine(">>> Employees working for " + orgName + ":");
foreach (var entry in qry)
Console.WriteLine(">>> " + entry.Value);
}
示例4: ScanQueryExample
/// <summary>
/// Queries employees that have provided ZIP code in address.
/// </summary>
/// <param name="cache">Cache.</param>
private static void ScanQueryExample(ICache<int, Employee> cache)
{
const int zip = 94109;
var qry = cache.Query(new ScanQuery<int, Employee>(new ScanQueryFilter(zip)));
Console.WriteLine();
Console.WriteLine(">>> Employees with zipcode {0} (scan):", zip);
foreach (var entry in qry)
Console.WriteLine(">>> " + entry.Value);
}
示例5: FullTextQueryExample
/// <summary>
/// Queries persons that have a specific name using full-text query API.
/// </summary>
/// <param name="cache">Cache.</param>
private static void FullTextQueryExample(ICache<int, IBinaryObject> cache)
{
var qry = cache.Query(new TextQuery(PersonType, "Peters"));
Console.WriteLine();
Console.WriteLine(">>> Persons named Peters:");
foreach (var entry in qry)
Console.WriteLine(">>> " + entry.Value);
}
示例6: SqlJoinQueryExample
/// <summary>
/// Queries persons that work for company with provided name.
/// </summary>
/// <param name="cache">Cache.</param>
private static void SqlJoinQueryExample(ICache<int, IBinaryObject> cache)
{
const string orgName = "Apache";
var qry = cache.Query(new SqlQuery(PersonType,
"from Person, Company " +
"where Person.CompanyId = Company.Id and Company.Name = ?", orgName));
Console.WriteLine();
Console.WriteLine(">>> Persons working for " + orgName + ":");
foreach (var entry in qry)
Console.WriteLine(">>> " + entry.Value);
}
示例7: SqlQueryExample
/// <summary>
/// Queries persons that have a specific name using SQL.
/// </summary>
/// <param name="cache">Cache.</param>
private static void SqlQueryExample(ICache<int, IBinaryObject> cache)
{
var qry = cache.Query(new SqlQuery(PersonType, "name like 'James%'"));
Console.WriteLine();
Console.WriteLine(">>> Persons named James:");
foreach (var entry in qry)
Console.WriteLine(">>> " + entry.Value);
}
示例8: SqlJoinQueryExample
/// <summary>
/// Queries employees that work for organization with provided name.
/// </summary>
/// <param name="cache">Cache.</param>
private static void SqlJoinQueryExample(ICache<EmployeeKey, Employee> cache)
{
const string orgName = "Apache";
var qry = cache.Query(new SqlQuery("Employee",
"from Employee, Organization " +
"where Employee.organizationId = Organization._key and Organization.name = ?", orgName));
Console.WriteLine();
Console.WriteLine(">>> Employees working for " + orgName + ":");
foreach (var entry in qry)
Console.WriteLine(">>> " + entry.Value);
}