internal static IQueryable CreateWhereExpression(IDictionary <string, object> parameters, IQueryable source, IDynamicQueryable queryable) { if (parameters != null && parameters.Count > 0) { //extract the where clause WhereClause clause = GetWhereClause(parameters); if (!String.IsNullOrEmpty(clause.Expression)) { //transform the current query with the where clause return(queryable.Where(source, clause.Expression, clause.Parameters)); } } return(source); }
internal static IQueryable CreateWhereExpression(IDictionary<string, object> parameters, IQueryable source, IDynamicQueryable queryable) { if (parameters != null && parameters.Count > 0) { //extract the where clause WhereClause clause = GetWhereClause(parameters); if (!String.IsNullOrEmpty(clause.Expression)) { //transform the current query with the where clause return queryable.Where(source, clause.Expression, clause.Parameters); } } return source; }
protected IQueryable ExecuteQueryExpressions(IQueryable source, QueryContext context) { if (source != null) { QueryCreatedEventArgs queryArgs = new QueryCreatedEventArgs(source); OnQueryCreated(queryArgs); source = queryArgs.Query ?? source; // Support the Dynamic Expression language used by LinqDataSource if (AutoGenerateWhereClause) { if (!String.IsNullOrEmpty(Where)) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.LinqDataSourceView_WhereAlreadySpecified, _owner.ID)); } source = QueryableDataSourceHelper.CreateWhereExpression(context.WhereParameters, source, _queryable); } else if (!String.IsNullOrEmpty(Where)) { source = _queryable.Where(source, Where, context.WhereParameters.ToEscapedParameterKeys(_owner)); } if (AutoGenerateOrderByClause) { if (!String.IsNullOrEmpty(OrderBy)) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.LinqDataSourceView_OrderByAlreadySpecified, _owner.ID)); } source = QueryableDataSourceHelper.CreateOrderByExpression(context.OrderByParameters, source, _queryable); } else if (!String.IsNullOrEmpty(OrderBy)) { source = _queryable.OrderBy(source, OrderBy, context.OrderByParameters.ToEscapedParameterKeys(_owner)); } string groupBy = GroupBy; if (String.IsNullOrEmpty(groupBy)) { if (!String.IsNullOrEmpty(OrderGroupsBy)) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.LinqDataSourceView_OrderGroupsByRequiresGroupBy, _owner.ID)); } } else { source = _queryable.GroupBy(source, groupBy, "it", context.GroupByParameters.ToEscapedParameterKeys(_owner)); if (!String.IsNullOrEmpty(OrderGroupsBy)) { source = _queryable.OrderBy(source, OrderGroupsBy, context.OrderGroupsByParameters.ToEscapedParameterKeys(_owner)); } } if (!String.IsNullOrEmpty(SelectNew)) { source = _queryable.Select(source, SelectNew, context.SelectParameters.ToEscapedParameterKeys(_owner)); } return(source); } return(source); }