MutableIdeas.Web.Linq.Query.Service
2.4.2
See the version list below for details.
dotnet add package MutableIdeas.Web.Linq.Query.Service --version 2.4.2
NuGet\Install-Package MutableIdeas.Web.Linq.Query.Service -Version 2.4.2
<PackageReference Include="MutableIdeas.Web.Linq.Query.Service" Version="2.4.2" />
paket add MutableIdeas.Web.Linq.Query.Service --version 2.4.2
#r "nuget: MutableIdeas.Web.Linq.Query.Service, 2.4.2"
// Install MutableIdeas.Web.Linq.Query.Service as a Cake Addin #addin nuget:?package=MutableIdeas.Web.Linq.Query.Service&version=2.4.2 // Install MutableIdeas.Web.Linq.Query.Service as a Cake Tool #tool nuget:?package=MutableIdeas.Web.Linq.Query.Service&version=2.4.2
MutableIdeas.Web.Linq.Query.Service
Parses a formatted string and that provides the user a an expression for filtering.
Parses a formatted string that will sort an entity set by its property be acsending or descending order.
Filtering
Format for Filtering
String values
propertyName comparison 'stringValue'
Numeric values
propertyName comparison numericvalue
Joined Filters
propertyName comparison 'value' operator propertyName comparison 'value'
Definitions
propertyName - The property name of the entity which to filter. Property names are not case sensitive.
comparison - The type of comparison on the property needed to filter
Valid comparison values are:
- eq - Equal
- lt - Less Than
- lte - Less Than or Equal to
- ne - Not Equal
- gt - Greater Than
- gte - Greater Than or Equal to
- ct - For string values, contains
- ctic - For string values, contains ignore case
- in - Looks for values in an array supplied
- leneq - the length of a string or an enumerable.Count is equal
- lenne - the length of a string or an enumerable.Count is not equal. This will include null values.
- lengt - the length of a string or an enumerable.Count is greater than
- lengte - the length of a string or an enumerable.Count is greater than or equal to
- lenlt - the length of a string or an enumerable.Count is less than. This will include null values.
- lenlte - the length of a string or an enumerable.Count is less than or equal to. This will include null values.
value - The value of the property you want to filter. String values need to be enclosed by single quotes and need to be URL ESCAPED.
operator
Valid operator values
- and
- or
Examples for Filtering
- name eq 'Red%20Wings' - Entity.Name == "Red Wings"
- name ne 'Avs' - Entity.Name != "Avs"
- name ct 'Red' - Entity.Name.Contains("Red")
- name ctic 'Red' - Entity.Name.ToLower().Contains("red")
- price gt 20 and price lt 50 - *Entity.Price > 20 && Entity.Price < 50
- price gte 20 and price lte 50 - Entity.Price ⇒ 20 && Entity.Price ⇐ 50
- name eq 'Red%20Wings' or price eq 5 - Entity.Name == "Red Wings" || Entity.Price == 5
Enumerables
Note - Enumerable properties must be initialized in your entities.
- enumerable in ['value1', 'value2', 'value3'] - * arrayValuesSupplied.Contains(Entity.enumerable.value);
- enumerable leneq 3 - Entity.Enumerable.Distinct().Count() == 3
- enumerable lenne 4 - Entity.Enumerable.Distinct().Count() != 4
- enumerable lengt 2 - Entity.Enumerable.Distinct().Count() > 2
- enumerable lengte 4 - Entity.Enumerable.Distinct().Count() >= 4
- enumerable lenlt 3 - Entity.Enumerable.Distinct().Count() < 3
- enumerable lenlte 3 - Entity.Enumerable.Distinct().Count() ⇐ 3
Nested Enumerables
- enumerable.enumerableProperty lengt 3 - Entity.Enumerable != null && Entity.Enumerable.Where(p ⇒ p.EnumerableProperty.Any()).SelectMany(p ⇒ p.EnumerableProperty).Distinct().Count() > 3
Assuming name is a string
- name leneq 3 - Entity.name != null && Entity. name.Length == 3
- name lenne 3 -Entity.name == null || Entity.name.Length != 3
- name lengt 2 - Entity.name != null && Entity.name.Length > 2
- name lengte 2 - Entity.name != null && Entity.name.Length >= 2
- name lenlt 3 - Entity.name == null || Entity.name.Length < 3
- name lenlte 3 - Entity.name == null || Entity.name.length ⇐ 3
Sorting
Format for Sorting
propertyName sortOrder
Definitions
propertyName - The property name of the entity which to filter. Property names are not case sensitive.
sortOrder (optional) - By default this will be in ascending order
Valid values for sortOrder
- asc - Ascending order
- desc - Descending order
- natasc - Natural sorting for string values in ascending order, ex: ⇒ ["C1", "C2", "C10"]
- natdesc - Natural sorting for string values in descending order, ex ⇒ ["C10", "C2", "C1"]
Examples for sorting
- name - default ascending order
- name desc - sort descending order
- name asc - sort ascending order
C# Services
QueryExpressionService<T>
Methods
Expression<Func<T, bool>> GetExpression(string filter)
- filter - From the filters listed above, this will parse the string and create and expression that can be used for filtering.
IQueryable<T> Sort(string sort, IQueryable<T> queryable)
This will sort the entities of the queryable parameter per the sort string.
- sort - From the sorting string listed above
- queryable - A queryable entity set
FilterService<T>
Methods
By(string propertyName, string value, FilterType filtertype)
Creates a filter expression by the propertyName, value, and the type of comparison.
And()
Adds the conditional And expression for the next expression.
Or()
Adds the conditional Or expression for the next expression.
Expression<Func<T, bool>> Build() Builds the Expression from the statements above and will clear the statements
Examples
var _filterService = new FilterService<SomeClass>();
_filterService.By("Name", "Red", FilterType.Equals);
_filterService.Or();
_filterService.By("Name", "Avs", FilterType.Equals);
Expression<Func<SomeClass, bool>> expression = _filterService.Build();
Fluent Extension
var _filterService = new FilterService<SomeClass>();
_filterService.By("Name", "Red", FilterType.Equals) .Or("Name", "Blue", FilterType.Equals) .And("Status", "1", FilterType.Equals")
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6
- MutableIdeas.Web.Linq.Query.Domain (>= 2.3.0)
- NaturalSort.Extension (>= 1.0.2)
-
.NETStandard 2.0
- MutableIdeas.Web.Linq.Query.Domain (>= 2.3.0)
- NaturalSort.Extension (>= 1.0.2)
- System.Linq.Queryable (>= 4.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.4.5 | 2,556 | 1/23/2019 |
2.4.4 | 845 | 12/27/2018 |
2.4.3 | 711 | 12/10/2018 |
2.4.2 | 735 | 10/23/2018 |
2.4.1 | 1,009 | 6/18/2018 |
2.4.0 | 942 | 3/14/2018 |
2.3.2 | 908 | 3/7/2018 |
2.3.1 | 953 | 2/12/2018 |
2.3.0 | 906 | 2/8/2018 |
2.2.1 | 1,041 | 2/2/2018 |
2.2.0 | 959 | 1/19/2018 |
2.1.6 | 977 | 1/11/2018 |
2.1.5 | 1,000 | 12/19/2017 |
2.1.4 | 930 | 12/17/2017 |
2.1.3 | 927 | 12/15/2017 |
2.1.2 | 906 | 12/15/2017 |
2.1.1 | 988 | 12/14/2017 |
2.1.0 | 873 | 12/12/2017 |
2.0.3 | 911 | 12/12/2017 |
2.0.2 | 947 | 12/12/2017 |
2.0.1 | 1,083 | 12/12/2017 |
2.0.0 | 862 | 12/11/2017 |
1.6.0 | 1,120 | 12/11/2017 |
1.5.1 | 918 | 12/9/2017 |
1.5.0 | 991 | 12/9/2017 |
1.4.4 | 1,030 | 12/6/2017 |
1.4.3 | 804 | 12/6/2017 |
1.4.2 | 927 | 11/29/2017 |
1.4.1 | 854 | 11/19/2017 |
1.4.0 | 818 | 11/19/2017 |
1.3.1 | 908 | 11/12/2017 |
1.3.0 | 821 | 11/12/2017 |
1.2.0 | 850 | 11/11/2017 |
1.1.0 | 813 | 11/6/2017 |
1.0.4 | 832 | 11/6/2017 |
1.0.3 | 817 | 11/6/2017 |
1.0.2 | 892 | 11/6/2017 |
1.0.1 | 873 | 11/5/2017 |
1.0.0 | 870 | 11/5/2017 |
Fixed an expression issue where HasValue is not respected by some expression parsers on nullable types