-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
389 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Raiqub.Expressions.Queries.Internal; | ||
|
||
namespace Raiqub.Expressions.Queries; | ||
|
||
public static class EntityQueryModel | ||
{ | ||
/// <summary> | ||
/// Returns a query model for the specified type <typeparamref name="T"/> that does nothing. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the elements of query model.</typeparam> | ||
/// <returns>A query model for the specified type <typeparamref name="T"/>.</returns> | ||
public static IEntityQueryModel<T> Create<T>() where T : class => | ||
AllQueryModel<T>.Instance; | ||
|
||
public static IEntityQueryModel<T> Create<T>(Specification<T> specification) where T : class => | ||
new SpecificationQueryModel<T>(specification); | ||
|
||
public static IEntityQueryModel<TSource, TResult> Create<TSource, TResult>( | ||
Func<IQueryable<TSource>, IQueryable<TResult>> queryModel) where TSource : class => | ||
new AnonymousEntityQueryModel<TSource, TResult>(queryModel); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Raiqub.Expressions.Queries; | ||
|
||
public abstract class EntityQueryModel<T> : EntityQueryModel<T, T>, IEntityQueryModel<T> | ||
where T : class | ||
{ | ||
protected override IQueryable<T> ExecuteCore(IQueryable<T> source) => source; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Raiqub.Expressions.Queries.Internal; | ||
|
||
internal sealed class AllQueryModel<T> : IEntityQueryModel<T>, IQueryModel<T> | ||
where T : class | ||
{ | ||
public static readonly AllQueryModel<T> Instance = new AllQueryModel<T>(); | ||
|
||
public IQueryable<T> Execute(IQueryable<T> source) => source; | ||
|
||
public IEnumerable<T> Execute(IEnumerable<T> source) => source; | ||
|
||
public IQueryable<T> Execute(IQuerySource source) => source.GetSet<T>(); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Expressions.Reading/Queries/Internal/AnonymousEntityQueryModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Raiqub.Expressions.Queries.Internal; | ||
|
||
internal sealed class AnonymousEntityQueryModel<TSource, TResult> | ||
: IEntityQueryModel<TSource, TResult>, IQueryModel<TResult> | ||
where TSource : class | ||
{ | ||
private readonly Func<IQueryable<TSource>, IQueryable<TResult>> _queryModel; | ||
|
||
public AnonymousEntityQueryModel(Func<IQueryable<TSource>, IQueryable<TResult>> queryModel) | ||
{ | ||
_queryModel = queryModel; | ||
} | ||
|
||
public IQueryable<TResult> Execute(IQueryable<TSource> source) => _queryModel(source); | ||
|
||
public IEnumerable<TResult> Execute(IEnumerable<TSource> source) => _queryModel(source.AsQueryable()); | ||
|
||
public IQueryable<TResult> Execute(IQuerySource source) => _queryModel(source.GetSet<TSource>()); | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Expressions.Reading/Queries/Internal/AnonymousQueryModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Raiqub.Expressions.Queries.Internal; | ||
|
||
internal sealed class AnonymousQueryModel<TResult> : IQueryModel<TResult> | ||
{ | ||
private readonly Func<IQuerySource, IQueryable<TResult>> _queryModel; | ||
|
||
public AnonymousQueryModel(Func<IQuerySource, IQueryable<TResult>> queryModel) => _queryModel = queryModel; | ||
|
||
public IQueryable<TResult> Execute(IQuerySource source) => _queryModel(source); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Expressions.Reading/Queries/Internal/DerivedEntityQueryModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Raiqub.Expressions.Queries.Internal; | ||
|
||
internal sealed class DerivedEntityQueryModel<TParent, TDerived> | ||
: IEntityQueryModel<TDerived>, IQueryModel<TDerived> | ||
where TDerived : class, TParent | ||
{ | ||
private readonly IEntityQueryModel<TDerived, TParent> _originalQueryModel; | ||
|
||
public DerivedEntityQueryModel(IEntityQueryModel<TDerived, TParent> originalQueryModel) => | ||
_originalQueryModel = originalQueryModel; | ||
|
||
public IQueryable<TDerived> Execute(IQueryable<TDerived> source) => | ||
_originalQueryModel.Execute(source).OfType<TDerived>(); | ||
|
||
public IEnumerable<TDerived> Execute(IEnumerable<TDerived> source) => | ||
_originalQueryModel.Execute(source).OfType<TDerived>(); | ||
|
||
public IQueryable<TDerived> Execute(IQuerySource source) => | ||
Execute(source.GetSet<TDerived>()); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Expressions.Reading/Queries/Internal/EntityQueryModelWrapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Raiqub.Expressions.Queries.Internal; | ||
|
||
internal sealed class EntityQueryModelWrapper<TSource, TResult> : IQueryModel<TResult> | ||
where TSource : class | ||
{ | ||
private readonly IEntityQueryModel<TSource, TResult> _entityQueryModel; | ||
|
||
public EntityQueryModelWrapper(IEntityQueryModel<TSource, TResult> entityQueryModel) | ||
{ | ||
_entityQueryModel = entityQueryModel; | ||
} | ||
|
||
public IQueryable<TResult> Execute(IQuerySource source) => source.GetSetUsing(_entityQueryModel); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Raiqub.Expressions.Queries.Internal; | ||
|
||
namespace Raiqub.Expressions.Queries; | ||
|
||
public static class QueryModel | ||
{ | ||
public static IQueryModel<TResult> Create<TResult>(Func<IQuerySource, IQueryable<TResult>> queryModel) => | ||
new AnonymousQueryModel<TResult>(queryModel); | ||
} |
Oops, something went wrong.