本文整理汇总了C#中SimpleQuery.Where方法的典型用法代码示例。如果您正苦于以下问题:C# SimpleQuery.Where方法的具体用法?C# SimpleQuery.Where怎么用?C# SimpleQuery.Where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleQuery
的用法示例。
在下文中一共展示了SimpleQuery.Where方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhereShouldSetCriteria
public void WhereShouldSetCriteria()
{
var query = new SimpleQuery(null, "foo");
var criteria = new SimpleExpression(1, 1, SimpleExpressionType.Equal);
query = query.Where(criteria);
Assert.AreSame(criteria, query.Clauses.OfType<WhereClause>().Single().Criteria);
}
示例2: Execute
public object Execute(DataStrategy dataStrategy, SimpleQuery query, InvokeMemberBinder binder, object[] args)
{
var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(query.TableName,
CreateCriteriaDictionary(binder,
args));
query = query.Where(criteriaExpression).Take(1);
return query.FirstOrDefault();
}
示例3: Execute
public object Execute(DataStrategy dataStrategy, SimpleQuery query, InvokeMemberBinder binder, object[] args)
{
var keyNames = dataStrategy.GetAdapter().GetKeyNames(query.TableName);
var dict = keyNames.Select((k, i) => new KeyValuePair<string, object>(k, args[i]));
query = query.Where(ExpressionHelper.CriteriaDictionaryToExpression(query.TableName, dict)).Take(1);
var result = query.FirstOrDefault();
if (result == null) return null;
return binder.Name.Equals("get", StringComparison.OrdinalIgnoreCase) ? result : ((IDictionary<string, object>) result).First().Value;
}
示例4: Execute
/// <summary>
/// Executes the command.
/// </summary>
/// <param name="dataStrategy">The data strategy.</param>
/// <param name="table"></param>
/// <param name="binder">The binder from the <see cref="DynamicTable"/> method invocation.</param>
/// <param name="args">The arguments from the <see cref="DynamicTable"/> method invocation.</param>
/// <returns></returns>
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
var query = new SimpleQuery(dataStrategy, table.GetQualifiedName());
if (args.Length == 1 && args[0] is SimpleExpression)
{
query = query.Where((SimpleExpression)args[0]);
}
return query.Exists();
}
示例5: GetResult
public virtual async Task<Paged<Entities.Url>> GetResult(Filter.Simple.Data.Filter filter, int? accountId = null)
{
filter.Resource = "Urls";
DataStrategy strategy = Database.Open();
var query = new SimpleQuery(strategy, filter.Resource);
var limit = _limit.Apply(filter);
var skip = _skip.Apply(filter);
dynamic accounts;
query = query.Join(ObjectReference.FromString("Accounts"), JoinType.Inner, out accounts)
.On(accounts.Id == new ObjectReference("AccountId", ObjectReference.FromString("Urls")))
.Select(
new ObjectReference("Id", ObjectReference.FromString("Urls")),
new ObjectReference("Address", ObjectReference.FromString("Urls")),
new ObjectReference("Id", ObjectReference.FromString("Accounts")).As("Account_Id"))
.Skip(_skip.Apply(filter))
.Take(_limit.Apply(filter));
if (accountId.HasValue)
{
var leftOperand = new ObjectReference("AccountId", ObjectReference.FromString("Urls"));
query.Where(new SimpleExpression(leftOperand, accountId, SimpleExpressionType.Equal));
}
if (filter.HasOrdering)
{
query = query.OrderBy(_order.Apply(filter), OrderByDirection.Ascending);
}
var data = await query.ToList<dynamic>();
var entities = AutoMapper.MapDynamic<Entities.Url>(data).ToList();
if (!entities.Any())
{
return null;
}
return new Paged<Entities.Url>
{
Limit = limit,
Skip = skip,
Data = entities
};
}
示例6: Execute
/// <summary>
/// Executes the command.
/// </summary>
/// <param name="dataStrategy">The data strategy.</param>
/// <param name="table"></param>
/// <param name="binder">The binder from the <see cref="DynamicTable"/> method invocation.</param>
/// <param name="args">The arguments from the <see cref="DynamicTable"/> method invocation.</param>
/// <returns></returns>
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
var query = new SimpleQuery(dataStrategy, table.GetQualifiedName());
if (args.Length == 1)
{
var criteria = args[0] as SimpleExpression;
if (criteria != null)
{
query = query.Where(criteria);
}
else
{
throw new BadExpressionException(binder.Name + " requires an expression.");
}
}
else if (args.Length != 0)
{
throw new BadExpressionException(binder.Name + " requires an expression.");
}
return query.Exists();
}
示例7: Execute
/// <summary>
/// Executes the command.
/// </summary>
/// <param name="dataStrategy">The data strategy.</param>
/// <param name="table"></param>
/// <param name="binder">The binder from the <see cref="DynamicTable"/> method invocation.</param>
/// <param name="args">The arguments from the <see cref="DynamicTable"/> method invocation.</param>
/// <returns></returns>
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
var query = new SimpleQuery(dataStrategy, table.GetQualifiedName());
if (args.Length == 1)
{
var expression = args[0] as SimpleExpression;
if (expression != null)
{
return query.Where(expression).Count();
}
else
{
throw new BadExpressionException("GetCount expects an expression or no parameters.");
}
}
else if (args.Length == 0)
{
return query.Count();
}
throw new ArgumentException("GetCount expects an expression or no parameters.");
}
示例8: Execute
public object Execute(DataStrategy dataStrategy, SimpleQuery query, InvokeMemberBinder binder, object[] args)
{
return query.Where((SimpleExpression) args[0]).Take(1).FirstOrDefault();
}