// /// <summary> /// Apply filter to an IQueryable from PrimeNG request. /// Filter: /// key of the dictionary is the field name, /// object is value(s) and match mode /// <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.LazyFilters( _loadEvent ); /// </code> /// </example> /// </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 where filters applied)</returns> public static IQueryable <T> LazyFilters <T>( this IQueryable <T> qry, LazyLoadEvent lle) { if (lle.filters != null) { foreach (var _o in lle.filters) { PropertyInfo _propertyInfo = typeof(T).GetProperty(_o.Key); Type _type = _propertyInfo.PropertyType; FilterMetadata _value = _o.Value; var whereClause = LazyDynamicFilterExpression <T>(_o.Key, (string)_value.matchMode, _value.value.ToString(), _type, ""); qry = qry.Where(whereClause); } } return(qry); }
public static IQueryable <T> LazyOrderBy <T>( this IQueryable <T> qry, LazyLoadEvent lle) { return(qry.OrderBy <T>(lle.sortField, lle.sortOrder)); }
public static IQueryable <T> LazySkipTake <T>(this IQueryable <T> qry, LazyLoadEvent lle) { return(qry.SkipTake <T>((int)lle.first, (int)lle.rows)); }