public static IQueryable <T> LazyFilters2 <T>( this IQueryable <T> qry, LazyLoadEvent2 lle) { if (lle.filters != null) { foreach (var _f in lle.filters) { PropertyInfo _propertyInfo = typeof(T).GetProperty(_f.Key); Type _type = _propertyInfo.PropertyType; FilterMetadata[] _values = _f.Value.Where(f => f.value != null).ToArray(); var count = 1; Expression <Func <T, bool> > whereClause = null; foreach (FilterMetadata _m in _values) { var whereTemp = LazyDynamicFilterExpression <T>(_f.Key, (string)_m.matchMode, _m.value.ToString(), _type, _m.@operator); if (count == 1) { whereClause = whereTemp; } else { if ([email protected]( ) == "or") { whereClause = whereClause.OrExpression(whereTemp); } else { whereClause = whereClause.AndExpression(whereTemp); } } count++; } qry = qry.Where(whereClause); } } return(qry); }
// /// <summary> /// Sort this IQueryable, with: /// sortField and /// sortOrder 1=ascending /// -1=descending /// <example> /// This sample shows how to call this method, where _incidentQuery /// is IQueryable of Incident: /// <code> /// JavaScriptSerializer _jsSlzr = new JavaScriptSerializer(); /// _loadEvent = (LazyLoadEvent) _jsSlzr.Deserialize( jsonString, typeof(LazyLoadEvent) ); /// _incidentQuery = _incidentQuery.LazyOrderBy( _loadEvent ); /// </code> /// </example> /// <note type="note"> /// 'OrderBy' must be called before the method 'Skip'. /// </note> /// </summary> /// <typeparam name="T">Some class (database)</typeparam> /// <param name="qry">IQueryable query of T (above class)</param> /// <param name="lle">PrimeNG lazy loading event (LazyLoadEvent2) structure</param> /// <returns>IQueryable query of T (with ascending or descending sort applied)</returns> public static IQueryable <T> LazyOrderBy2 <T>( this IQueryable <T> qry, LazyLoadEvent2 lle) { return(qry.OrderBy <T>(lle.sortField, lle.sortOrder)); }
// /// <summary> /// Skip forward in the database and take n # of rows /// <example> /// This sample shows how to call this method, where _incidentQuery /// is IQueryable of Incident: /// <code> /// JavaScriptSerializer _jsSlzr = new JavaScriptSerializer(); /// _loadEvent = (LazyLoadEvent) _jsSlzr.Deserialize( jsonString, typeof(LazyLoadEvent) ); /// _incidentQuery = _incidentQuery.LazySkipTake( _loadEvent ); /// </code> /// </example> /// <note type="note"> /// 'OrderBy' must be called before the method 'Skip'. /// </note> /// </summary> /// <typeparam name="T">Some class (database)</typeparam> /// <param name="qry">IQueryable query of T (above class)</param> /// <param name="lle">PrimeNG lazy loading event (LazyLoadEvent) structure</param> /// <returns>IQueryable query of T (with skip/take applied)</returns> public static IQueryable <T> LazySkipTake2 <T>(this IQueryable <T> qry, LazyLoadEvent2 lle) { return(qry.SkipTake <T>((int)lle.first, (int)lle.rows)); }