NSG.PrimeNG.LazyLoading - PHuhn/NSG.PrimeNG GitHub Wiki
Json of interface: {"value":"S","matchMode":"startsWith","operator":"and"}
value: any string/numeric/etc
matchMode: string, with values of: gt/lt/equals/lte/gte/notequals/contains/startswith/endswith
operator: string and/or
Json of class: {"value":"S","matchMode":"startsWith","operator":"and"}
value: any string/numeric/etc
matchMode: string, with values of: gt/lt/equals/lte/gte/notequals/contains/startswith/endswith
operator: string and/or
PrimeNG structure, used by lazy loading feature. Class LazyLoadEvent ported from PrimeNG to this library. Generally, populated by the PrimeNG filter feature.
For example: An example of the JSON: {"first":0,"rows":3,"sortOrder":1, "filters":{"ServerId":{"value":1,"matchMode":"eq"}, "Mailed":{"value":"false","matchMode":"eq"}, "Closed":{"value":"false","matchMode":"eq"}, "Special":{"value":"false","matchMode":"eq"}}, "globalFilter":null}
First record #.
- of rows to return (page size).
Sort field.
Ascending or desending sort order. 1 = asc, -1 = desc
multiSortMeta, not implemented.
A dictionary of filters. Key of the dictionary is the field name, object is value(s) and match mode.
For example: "filters":{"ServerId":{"value":1,"matchMode":"eq"}, "Mailed":{"value":"false","matchMode":"eq"}, "Closed":{"value":"false","matchMode":"eq"}, "Special":{"value":"false","matchMode":"eq"}},
globalFilter, not implemented.
Returns a string that represents of the current object. This method overrides the default 'to string' method.
A formatted string of the object's values.
PrimeNG structure, used by lazy loading feature. Class LazyLoadEvent ported from PrimeNG to this library. Generally, populated by the PrimeNG filter feature.
For example: An example of the JSON: {"first":0,"rows":5,"sortOrder":1,"filters":{ "NoteTypeDesc":[ {"value":"F","matchMode":"startsWith","operator":"and"}, {], "NoteTypeShortDesc":[ {"value":"S","matchMode":"startsWith","operator":"and"}] },"globalFilter":null}
First record #.
- of rows to return (page size).
Sort field.
Ascending or desending sort order. 1 = asc, -1 = desc
multiSortMeta, not implemented.
A dictionary of filters. Key of the dictionary is the field name, object is value(s) and match mode.
For example: "filters":{"ServerId":{"value":1,"matchMode":"eq"}, "Mailed":{"value":"false","matchMode":"eq"}, "Closed":{"value":"false","matchMode":"eq"}, "Special":{"value":"false","matchMode":"eq"}},
globalFilter, not implemented.
Returns a string that represents of the current object. This method overrides the default 'to string' method.
For example: LazyLoadEvent2:[first:]
A formatted string of the object's values.
The namespace contains a class used by lazy loading feature and filter features. The lazy loading feature allows one to return a page of data and combined with the filtering and sorting features gives a rich feature of transferring large set of data efficiently.
For example: A full example of the original LazyLoadEvent as follows:
string _jsonString =
"{\"first\":0,\"rows\":3," +
"\"sortOrder\":-1,\"sortField\":\"NoteTypeSortOrder\"," +
"\"filters\":{\"NoteTypeDesc\":{\"value\":\"SO\",\"matchMode\":\"StartsWith\"}}}";
JavaScriptSerializer _js_slzr = new JavaScriptSerializer();
LazyLoadEvent _loadEvent = (LazyLoadEvent)_js_slzr.Deserialize(_jsonString, typeof(LazyLoadEvent));
List<NoteType> _rows = NoteTypes.AsQueryable()
.LazyOrderBy(_loadEvent)
.LazyFilters(_loadEvent)
.LazySkipTake(_loadEvent).ToList();
For example: A full example of the of corrected LazyLoadEvent2 as follows:
string _pagination = "{\"first\":0,\"rows\":3," +
"\"sortOrder\":-1,\"sortField\":\"NoteTypeSortOrder\"," +
"{\"filters\":{\"NoteTypeDesc\":[" +
"{\"value\":\"SO\",\"matchMode\":\"startsWith\",\"operator\":\"or\"}," +
"{\"value\":\"6\",\"matchMode\":\"contains\",\"operator\":\"or\"}]}}";
LazyLoadEvent2 _loadEvent = JsonConvert.DeserializeObject<LazyLoadEvent2>(_pagination);
List<NoteType> _rows = NoteTypes.AsQueryable()
.LazyOrderBy2(_loadEvent)
.LazyFilters2(_loadEvent)
.LazySkipTake2(_loadEvent).ToList();
Set of static helper methods, meant to be used as extension methods.
Sort this IQueryable, with: sortField and sortOrder 1=ascending -1=descending
For example: This sample shows how to call this method, where _incidentQuery is IQueryable of Incident:
JavaScriptSerializer _jsSlzr = new JavaScriptSerializer();
_loadEvent = (LazyLoadEvent) _jsSlzr.Deserialize( jsonString, typeof(LazyLoadEvent) );
_incidentQuery = _incidentQuery.LazyOrderBy( _loadEvent );
Note: 'OrderBy' must be called before the method 'Skip'.
Some class (database)
IQueryable query of T (above class)
PrimeNG lazy loading event (LazyLoadEvent2) structure
IQueryable query of T (with ascending or descending sort applied)
Skip forward in the database and take n # of rows
For example: This sample shows how to call this method, where _incidentQuery is IQueryable of Incident:
JavaScriptSerializer _jsSlzr = new JavaScriptSerializer();
_loadEvent = (LazyLoadEvent) _jsSlzr.Deserialize( jsonString, typeof(LazyLoadEvent) );
_incidentQuery = _incidentQuery.LazySkipTake( _loadEvent );
Note: 'OrderBy' must be called before the method 'Skip'.
Some class (database)
IQueryable query of T (above class)
PrimeNG lazy loading event (LazyLoadEvent) structure
IQueryable query of T (with skip/take applied)
Apply filter to an IQueryable from PrimeNG request. Filter: key of the dictionary is the field name, object is value(s) and match mode
For example: This sample shows how to call this method, where _incidentQuery is IQueryable of Incident:
JavaScriptSerializer _jsSlzr = new JavaScriptSerializer();
_loadEvent = (LazyLoadEvent) _jsSlzr.Deserialize( jsonString, typeof(LazyLoadEvent) );
_incidentQuery = _incidentQuery.LazyFilters( _loadEvent );
Some class (database)
IQueryable query of T (above class)
PrimeNG lazy loading event (LazyLoadEvent) structure
IQueryable query of T (with where filters applied)
OrExpression<T>(Linq.Expressions.Expression{System.Func<T>System.Boolean}}, Linq.Expressions.Expression{System.Func<T>System.Boolean}})
Implement an Or conditional
Some class (database)
The left (this) expression
The right expression
An expression that can be used for querying data sets
AndExpression<T>(Linq.Expressions.Expression{System.Func<T>System.Boolean}}, Linq.Expressions.Expression{System.Func<T>System.Boolean}})
Implement an And conditional
Some class (database)
The left (this) expression
The right expression
An expression that can be used for querying data sets
A method to create an expression dynamically given a generic entity, and a propertyName, operator and value.
- Operators
- contains
- startsWith
- endsWith
- equals
- notEquals
- lt
- lte
- gt
- gte
Note: The 'in' operator is not handled and will throw an exception:
Unhandled or invalid operators
The class to create the expression for. Most commonly an entity framework entity that is used for a DbSet.
A string value of the property name.
A string representing an operator (see above list of operators).
A string representation of the value.
The underlying type of the value
operator and/or
An expression that can be used for querying data sets (Expression>)
Extract this string value as the passed in object type (convert/cast).
The value, as a string
The desired type
The value, as the specified type
a list sorting item, can be sorted on multiple fields
field: field name to sort
order: accending/descending
a list sorting item, can be sorted on multiple fields
field: field name to sort
order: accending/descending