Skip to content

Commit 57cbbbf

Browse files
authored
Merge pull request #31 from trenoncourt/develop
Develop
2 parents ae08e82 + 9d916ac commit 57cbbbf

File tree

19 files changed

+120
-48
lines changed

19 files changed

+120
-48
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,22 @@ public class UsersController : Controller
163163
```
164164
*Note that Dto projection is the best way to limit selectable properties*
165165

166+
## Use base type instead of dynamic types
167+
AQ uses dynamic types per default to ensure that the final flow will be as small as possible. In some cases you may not want to use dynamic types, there is a property for this:
168+
```c#
169+
[Route("api/[controller]")]
170+
public class UsersController : Controller
171+
{
172+
[HttpGet]
173+
[AutoQueryable(UseBaseType = true)]
174+
public IQueryable<User> Get([FromServices] myDbContext dbContext)
175+
{
176+
return dbContext.User;
177+
}
178+
}
179+
```
180+
*Note that final flow will include null and default values but you can escape them with serializer settings for exemple*
181+
166182
## Use AutoQueryable without attribute
167183
If you don't want to use autoqueryable attribute you could use AQ directry in your code by passing it the querystring.
168184
First install the Autoqueryable package
@@ -192,8 +208,8 @@ public class UsersController
192208
- Add capability to use Group by
193209
- Add capability to set AutoQueryable options in headers
194210
- Add capability to choose to ignore case or not (case is ignored for now)
195-
- Add an option to not use dynamic objects (Use the type T provided by the IQueryable<T>)
196211
- Add Odata-v(x) & others as plugin (choose beetween AutoQueryable, Odata or others for query)
212+
- ~~Add an option to not use dynamic objects (Use the type T provided by the IQueryable\<T>)~~
197213
- ~~Add **Top**, **Skip**, **Take**, **OrderBy** keywords~~
198214
- ~~Add capability to include navidation properties (aka expand in OData)~~
199215
- ~~Add capability to select properties (columns in table)~~

sample/AutoQueryable.Sample.EfCore/Controllers/ProductController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using AutoQueryable.Sample.EfCore.Contexts;
77
using AutoQueryable.Sample.EfCore.Dtos;
88
using Microsoft.AspNetCore.Mvc;
9+
using AutoQueryable.Sample.EfCore.Entities;
910

1011
namespace AutoQueryable.Sample.EfCore.Controllers
1112
{
@@ -20,7 +21,7 @@ public class ProductController : ControllerBase
2021
/// <example>http://localhost:5000/api/products?select=name&top=50&skip=10</example>
2122
/// <param name="context"></param>
2223
/// <returns></returns>
23-
[AutoQueryable]
24+
[AutoQueryable(UseBaseType = true)]
2425
[HttpGet]
2526
public IQueryable Get([FromServices] AutoQueryableContext context)
2627
{

sample/AutoQueryable.Sample.EfCore/Entities/ProductModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public ProductModel()
1616
public Guid Rowguid { get; set; }
1717
public DateTime ModifiedDate { get; set; }
1818

19-
public virtual ICollection<Product> Product { get; set; }
19+
public virtual IEnumerable<Product> Product { get; set; }
2020
}
2121
}

sample/AutoQueryable.Sample.EfCore/Startup.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public void ConfigureServices(IServiceCollection services)
2020
.AddJsonFormatters(settings =>
2121
{
2222
settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
23-
settings.NullValueHandling = NullValueHandling.Ignore;
2423
settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
2524
});
2625

src/AutoQueryable.AspNet.Filter/AutoQueryable.AspNet.Filter.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<PropertyGroup>
44
<Description>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net &gt;=4.6.</Description>
55
<AssemblyTitle>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net &gt;=4.6.</AssemblyTitle>
6-
<VersionPrefix>1.3.0</VersionPrefix>
7-
<Version>1.3.0</Version>
6+
<VersionPrefix>1.4.0</VersionPrefix>
7+
<Version>1.4.0</Version>
88
<Authors>Thibaut Renoncourt</Authors>
99
<TargetFramework>net46</TargetFramework>
1010
<AssemblyName>AutoQueryable.AspNet.Filter</AssemblyName>

src/AutoQueryable.AspNetCore.Filter/AutoQueryable.AspNetCore.Filter.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<PropertyGroup>
44
<Description>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net Core.</Description>
55
<AssemblyTitle>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net Core.</AssemblyTitle>
6-
<VersionPrefix>1.3.0</VersionPrefix>
7-
<Version>1.3.0</Version>
6+
<VersionPrefix>1.4.0</VersionPrefix>
7+
<Version>1.4.0</Version>
88
<Authors>Thibaut Renoncourt</Authors>
99
<TargetFramework>netstandard1.6</TargetFramework>
1010
<AssemblyName>AutoQueryable.AspNetCore.Filter</AssemblyName>

src/AutoQueryable.AspNetCore.Filter/FilterAttributes/AutoQueryableAttribute.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public class AutoQueryableAttribute : ActionFilterAttribute
4141

4242
public ProviderType ProviderType { get; set; }
4343

44+
public bool UseBaseType { get; set; }
45+
4446
public override void OnActionExecuted(ActionExecutedContext context)
4547
{
4648
dynamic query = ((ObjectResult)context.Result).Value;
@@ -65,7 +67,8 @@ public override void OnActionExecuted(ActionExecutedContext context)
6567
MaxToTake = MaxToTake,
6668
MaxToSkip = MaxToSkip,
6769
MaxDepth = MaxDepth,
68-
ProviderType = ProviderType
70+
ProviderType = ProviderType,
71+
UseBaseType = UseBaseType
6972
}));
7073
}
7174
}

src/AutoQueryable.Core/AutoQueryable.Core.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>netstandard1.3</TargetFrameworks>
4-
<VersionPrefix>1.3.0</VersionPrefix>
5-
<Version>1.3.0</Version>
6-
<AssemblyVersion>1.3.0.0</AssemblyVersion>
7-
<FileVersion>1.3.0.0</FileVersion>
4+
<VersionPrefix>1.4.0</VersionPrefix>
5+
<Version>1.4.0</Version>
6+
<AssemblyVersion>1.4.0.0</AssemblyVersion>
7+
<FileVersion>1.4.0.0</FileVersion>
88
</PropertyGroup>
99
<ItemGroup>
1010
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />

src/AutoQueryable.Core/Models/AutoQueryableProfile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@ public class AutoQueryableProfile
3636
public int? MaxDepth { get; set; }
3737

3838
public ProviderType ProviderType { get; set; } = ProviderType.Default;
39+
40+
public bool UseBaseType { get; set; }
3941
}
4042
}

src/AutoQueryable.Nancy.Filter/AutoQueryable.Nancy.Filter.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<TargetFramework>netstandard1.6</TargetFramework>
55
<Description>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Nancy.</Description>
66
<Authors>Thibaut Renoncourt</Authors>
7-
<VersionPrefix>1.3.0</VersionPrefix>
8-
<Version>1.3.0</Version>
7+
<VersionPrefix>1.4.0</VersionPrefix>
8+
<Version>1.4.0</Version>
99
<PackageLicenseUrl>https://raw.githubusercontent.com/trenoncourt/AutoQueryable/master/LICENSE</PackageLicenseUrl>
1010
<PackageProjectUrl>https://github.com/trenoncourt/AutoQueryable</PackageProjectUrl>
1111
<PackageTags>AutoQueryable;AutoQuery;OData;GraphQL</PackageTags>

0 commit comments

Comments
 (0)