MQuery 0.1.1
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package MQuery --version 0.1.1
NuGet\Install-Package MQuery -Version 0.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MQuery" Version="0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MQuery" Version="0.1.1" />
<PackageReference Include="MQuery" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MQuery --version 0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MQuery, 0.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MQuery@0.1.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MQuery&version=0.1.1
#tool nuget:?package=MQuery&version=0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MQuery
使用 MQuery 你能得到什么?
使用 MQuery 只需要个位数的代码量,就能构建 ASP.NET Core WebApi 上的任意字段的简单查询,例如
原始数据
[
{ "id": 1, "username": "Alice", "age": 18, "country": "USA" },
{ "id": 2, "username": "Bob", "age": 20, "country": "UK" },
{ "id": 3, "username": "Carl", "age": 47, "country": "Canada" },
{ "id": 4, "username": "Daniel", "age": 50, "country": "USA" },
{ "id": 5, "username": "Eva", "age": 35, "country": "Poland" },
{ "id": 6, "username": "Fiona", "age": null, "country": "Russia" },
]
查询 username 为“Alice”的数据
{your-api-path}?username=Alice
结果
[
{ "id": 1, "username": "Alice", "age": 18, "country": "USA" },
]
☞ 具体语法
如何使用
在 ASP.NET Core WebApi 中使用MQuery
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers(options=>
{
options.AddMQuery(o =>
{
o.DefaultLimit = 50; // 设置默认的分页条目数
o.MaxLimit = 50; // 设置最大的分页条目数
});
});
}
BlogsController.cs
[HttpGet("api/blogs")]
public ActionResult<IEnumerable<Blog>> Query(Query<Blog> query)
{
return query.ApplyTo(db.Blogs).ToList();
}
你也可以单独进行筛选、排序以及分页
单独进行筛选
query.FilterTo(blogs);
单独进行排序
query.SortTo(blogs);
单独进行分页
query.SliceTo(blogs);
从字符串中创建Query
var query = new QueryParser<Foo>().Parse("name[$ne]=Alice&age[$gte]=18&age[$lt]=40&$sort[age]=-1&$skip=1&$limit=2");
| 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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 | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
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 |
|---|