lynMarkdigRenderTest75 1.0.0
dotnet add package lynMarkdigRenderTest75 --version 1.0.0
NuGet\Install-Package lynMarkdigRenderTest75 -Version 1.0.0
<PackageReference Include="lynMarkdigRenderTest75" Version="1.0.0" />
paket add lynMarkdigRenderTest75 --version 1.0.0
#r "nuget: lynMarkdigRenderTest75, 1.0.0"
// Install lynMarkdigRenderTest75 as a Cake Addin #addin nuget:?package=lynMarkdigRenderTest75&version=1.0.0 // Install lynMarkdigRenderTest75 as a Cake Tool #tool nuget:?package=lynMarkdigRenderTest75&version=1.0.0
Extensions.Linq
Opinionated System.Linq extensions for common operation, favoring fail fast philosophy.
-If type extensions
- WhereIf
- TakeIf
- SkipIf
Allows queueing of multiple linq queries naturally instead of breaking the flow to provide condition checking. Typical example in an API trying to implement queries:
var query = DbContext.EntityName.Where(x=>true);
if (!string.IsNullOrEmpty(parameters.NameFilter)) {
query = query.Where(x=> x.Name.Contains(parametersNameFilter))
}
[...]
Apart from the cognitive issues added by such a syntax, developers new to Entity Framework or hasty code writing might end up in something resembling
var query = DbContext.EntityName.AsQueryable()
This is a major issue, as the extension method AsQueryable
is not available in DbSet
or IQueryable
, but in IEnumerable
, to which both DbSet and Queryable can be converted implicitly. This would force loading data for the entire table, and even worse, leaves an open database cursor, eventually leading to availability issues.
Compare this to the safe and natural Linq syntax provided by these methods
var query = DbContext.EntityName
.WhereIf(
!string.IsNullOrEmpty(parameters.NameFilter),
x=> x.Name.Contains(parametersNameFilter))
[...]
Ordering Extensions
- OrderByProperty
- OrderByPropertyDescending
- ThenByProperty
- ThenByPropertyDescending
Provides a set of methods allowing ordering a queryable by a property name (passed in as string). Also, an overload accepting a fallback selector is provided, in case the property does not exist on the specified type, or the property string is not populated.
Important information: As it should be apparent, this method of ordering relies on reflection. However, leveraging the dynamic keyword, polymorphic inline caching is used, so the reflection cost is paid only for the first time any such extension method is called for each type.
Initial implementation was a collaboration with palladin
Pagination Extensions
- Slice
Simple and safe method to extract pages from Queryable datasets. Only available on IOrderedQueryable
since this is the only way data parity can be enforced.
Deconstruction Extensions
Provides deconstruct extension methods for all expressions under the System.Linq.Expressions namespace, for easy pattern matching, especially when leveraging the swich expression new to C# 8.0. Requested, and guided, by palladin.
Feature was developed to faciliate the following kind of syntax, in order to provide the base for expression splicing, collaborated under nessos/Splicer:
expr = x => x + initial;
var restructured = expr switch
{
LambdaExpression(var param, BinaryExpression(ExpressionType.Add, var left, ConstantExpression(ExpressionType.Constant, _, initial)))
=> Expression.Lambda(Expression.Add(left, Expression.Constant(addInstead)), param.ToArray()),
_
=> throw new NotSupportedException()
};
Contributors
- palladin, aka @NickPalladinos, high priest of the Old Ones, providing tips and guidance in return for blood sacrifice.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
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 |
---|---|---|
1.0.0 | 0 | 11/24/2020 |