kemsky / projection-tools Goto Github PK
View Code? Open in Web Editor NEWPrimitives for building reusable LINQ projections and specifications
License: MIT License
Primitives for building reusable LINQ projections and specifications
License: MIT License
dotnet validate package local ProjectionTools.1.0.11.nupkg
Validating /home/dookie/Documents/projects/ProjectionTools/ProjectionTools.1.0.11.nupkg
• Source Link: ✅ Valid
• Deterministic (dll/exe): ❌ Non deterministic
Ensure that the following property is enabled for CI builds
and you're using at least the 2.1.300 SDK:
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
The following assemblies have not been compiled with deterministic settings:
lib\netstandard2.0\ProjectionTools.dll
• Compiler Flags: ✅ Valid
Using NuGetPackageExplorer:
dotnet validate package local ProjectionTools.1.0.XX.nupkg
Something like EnsureAllPropertiesMapped()
Some errors may be observed only in runtime, we can add a flag to trigger eager evaluation and get immediate feedback on start. For example, it can be enabled only in debug mode.
Sometimes we may want to control when fields should be mapped.
Projection<DepartmentEntity, DepartmentDto> DepartmentDtoProjection = new (
(x, context) => new DepartmentDto
{
Name = x.Name,
// marker compatible with delegates, can we keep original Description value?
Description = context.When(context.WithDescription, x.Description /* default value? */)
}
);
Custom extension methods break EF translation, but we can rewrite them.
public static readonly Projection<DepartmentEntity, DepartmentDto> DepartmentDtoProjection = new (
x => new DepartmentDto
{
Name = x.Name,
Status = x.Status.ToDtoStatus()
}
);
public static StatusDto ToDtoStatus(this Status status)
{
return StatusDtoProjection.Project(status);
}
Can be translated to:
public static readonly Projection<DepartmentEntity, DepartmentDto> DepartmentDtoProjection = new (
x => new DepartmentDto
{
Name = x.Name,
Status = StatusDtoProjection.Project(x.Status)
}
);
public static partial class Specifications
{
private static readonly Specification<string> MySpec1Generate = new Specification<string>(x => x.Length > 0);
private static readonly Specification<string> MySpec2Generate = new Specification<string>(x => x.Length > 5) && MySpec1Generate;
private static readonly Specification<string> MySpec3Generate = new (x => MySpec2Generate.IsSatisfiedBy(x));
}
public static partial class SpecificationsGenerated
{
public static readonly Specification<string> MySpec1 = new (x => x.Length > 0, x => x.Length > 0);
public static readonly Specification<string> MySpec2 = new (x => x.Length > 5 && x.Length > 0, x => x.Length > 5 && x.Length > 0);
public static readonly Specification<string> MySpec3 = new (x => x.Length > 5 && x.Length > 0, x => x.Length > 5 && x.Length > 0);
}
This can eliminate all expression machinery, delegate compilation and de-compilation.
How can we handle more complex cases when we reuse specification objects?
https://www.thinktecture.com/net/roslyn-source-generators-introduction/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.