-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Entity Manager supporting explicit CancellationToken passed as argume…
…nt; HttpRequest cancellation source; Dynamic LINQ filters to Entity Manager
- Loading branch information
Showing
17 changed files
with
639 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Contributing to Deveel Repository | ||
|
||
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: | ||
|
||
- Reporting a bug | ||
- Discussing the current state of the code | ||
- Submitting a fix | ||
- Proposing new features | ||
- Becoming a maintainer | ||
|
||
## We Develop with Github | ||
We use github to host code, to track issues and feature requests, as well as accept pull requests. | ||
|
||
## GitHub Flow | ||
|
||
We use the [Github Flow](https://guides.github.com/introduction/flow/index.html) that basically means that all code changes happen through pull requests. | ||
|
||
Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests: | ||
|
||
1. Fork the repo and create your branch from `main`. | ||
2. If you've added code that should be tested, add tests. | ||
3. If you've changed APIs, update the documentation. | ||
4. Ensure the test suite passes. | ||
5. Make sure your code lints. | ||
6. Issue that pull request! | ||
|
||
## License of Your Contributions | ||
|
||
In short, when you submit code changes, your submissions are understood to be under the same [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0) that covers the project. Feel free to contact the maintainers if that's a concern. | ||
|
||
## Reporting Bugs | ||
|
||
We use GitHub [issues](https://github.com/deveel/deveel.repository/issues) to track public bugs. Report a bug by [opening a new issue](); it's that easy! | ||
|
||
### Write bug reports with detail, background, and sample code | ||
|
||
[This is an example](http://stackoverflow.com/q/12488905/180626) of a bug report I wrote, and I think it's not a bad model. Here's [another example from Craig Hockenberry](http://www.openradar.me/11905408), an app developer whom I greatly respect. | ||
|
||
**Great Bug Reports** tend to have: | ||
|
||
- A quick summary and/or background | ||
- Steps to reproduce | ||
- Be specific! | ||
- Give sample code if you can. [My stackoverflow question](http://stackoverflow.com/q/12488905/180626) includes sample code that *anyone* with a base R setup can run to reproduce what I was seeing | ||
- What you expected would happen | ||
- What actually happens | ||
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work) | ||
|
||
People *love* thorough bug reports. I'm not even kidding. |
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
92 changes: 92 additions & 0 deletions
92
src/Deveel.Repository.Manager.DynamicLinq/Data/EntityManagerExtensions.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,92 @@ | ||
// Copyright 2023 Deveel AS | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace Deveel.Data { | ||
/// <summary> | ||
/// Extends the <see cref="EntityManager{TEntity}"/> to provide | ||
/// filtering capabilities using a dynamic LINQ expression. | ||
/// </summary> | ||
/// <seealso cref="DynamicLinqFilter"/> | ||
public static class EntityManagerExtensions { | ||
/// <summary> | ||
/// Finds the first entity in the repository that matches the given | ||
/// dynamic LINQ expression. | ||
/// </summary> | ||
/// <typeparam name="TEntity"> | ||
/// The type of the entity to find. | ||
/// </typeparam> | ||
/// <param name="manager"> | ||
/// The entity manager to use to find the entity. | ||
/// </param> | ||
/// <param name="expression"> | ||
/// The dynamic LINQ expression to use to filter the entity. | ||
/// </param> | ||
/// <param name="cancellationToken"> | ||
/// A token to cancel the operation. | ||
/// </param> | ||
/// <returns> | ||
/// Returns the first entity that matches the given expression, or | ||
/// <c>null</c> if no entity was found. | ||
/// </returns> | ||
public static Task<TEntity?> FindFirstAsync<TEntity>(this EntityManager<TEntity> manager, string expression, CancellationToken? cancellationToken = null) | ||
where TEntity : class | ||
=> manager.FindFirstAsync(new DynamicLinqFilter(expression), cancellationToken); | ||
|
||
/// <summary> | ||
/// Finds a range of entities in the repository that matches the given | ||
/// dynamic LINQ expression. | ||
/// </summary> | ||
/// <typeparam name="TEntity"> | ||
/// The type of the entity to find. | ||
/// </typeparam> | ||
/// <param name="manager"> | ||
/// The entity manager to use to find the entity. | ||
/// </param> | ||
/// <param name="expression"> | ||
/// The dynamic LINQ expression to use to filter the entity. | ||
/// </param> | ||
/// <param name="cancellationToken"> | ||
/// A token to cancel the operation. | ||
/// </param> | ||
/// <returns> | ||
/// Returns a list of entities that matches the given expression. | ||
/// </returns> | ||
public static Task<IList<TEntity>> FindAllAsync<TEntity>(this EntityManager<TEntity> manager, string expression, CancellationToken? cancellationToken = null) | ||
where TEntity : class | ||
=> manager.FindAllAsync(new DynamicLinqFilter(expression), cancellationToken); | ||
|
||
/// <summary> | ||
/// Counts the number of entities in the repository that matches the | ||
/// dynamic LINQ expression. | ||
/// </summary> | ||
/// <typeparam name="TEntity"> | ||
/// The type of the entity to count. | ||
/// </typeparam> | ||
/// <param name="manager"> | ||
/// The entity manager to use to count the entities. | ||
/// </param> | ||
/// <param name="expression"> | ||
/// The dynamic LINQ expression to use to filter the entity. | ||
/// </param> | ||
/// <param name="cancellationToken"> | ||
/// A token to cancel the operation. | ||
/// </param> | ||
/// <returns> | ||
/// Returns the number of entities that matches the given expression. | ||
/// </returns> | ||
public static Task<long> CountAsync<TEntity>(this EntityManager<TEntity> manager, string expression, CancellationToken? cancellationToken = null) | ||
where TEntity : class | ||
=> manager.CountAsync(new DynamicLinqFilter(expression), cancellationToken); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Deveel.Repository.Manager.DynamicLinq/Deveel.Repository.Manager.DynamicLinq.csproj
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Deveel.Repository.DynamicLinq\Deveel.Repository.DynamicLinq.csproj" /> | ||
<ProjectReference Include="..\Deveel.Repository.Manager\Deveel.Repository.Manager.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.