Skip to content

Commit

Permalink
Merge pull request #46 from trenoncourt/develop
Browse files Browse the repository at this point in the history
1.6.0
  • Loading branch information
trenoncourt authored Apr 7, 2018
2 parents 8e70878 + 6ded6f2 commit 97202b4
Show file tree
Hide file tree
Showing 52 changed files with 1,334 additions and 709 deletions.
14 changes: 0 additions & 14 deletions AutoQueryable.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoQueryable.Nancy.Filter"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoQueryable.Sample.Nancy", "sample\AutoQueryable.Sample.Nancy\AutoQueryable.Sample.Nancy.csproj", "{5D231472-9941-4E90-950B-3709583E832A}"

EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoQueryable.Core", "src\AutoQueryable.Core\AutoQueryable.Core.csproj", "{D8FBFF88-111D-41F8-A958-7C6FB66FAC9F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoQueryable.Providers.OData", "src\AutoQueryable.Providers.OData\AutoQueryable.Providers.OData.csproj", "{8335B90F-6465-4882-9DA0-460BE0EA8DF4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -66,14 +62,6 @@ Global
{5D231472-9941-4E90-950B-3709583E832A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D231472-9941-4E90-950B-3709583E832A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D231472-9941-4E90-950B-3709583E832A}.Release|Any CPU.Build.0 = Release|Any CPU
{D8FBFF88-111D-41F8-A958-7C6FB66FAC9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8FBFF88-111D-41F8-A958-7C6FB66FAC9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8FBFF88-111D-41F8-A958-7C6FB66FAC9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8FBFF88-111D-41F8-A958-7C6FB66FAC9F}.Release|Any CPU.Build.0 = Release|Any CPU
{8335B90F-6465-4882-9DA0-460BE0EA8DF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8335B90F-6465-4882-9DA0-460BE0EA8DF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8335B90F-6465-4882-9DA0-460BE0EA8DF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8335B90F-6465-4882-9DA0-460BE0EA8DF4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -86,7 +74,5 @@ Global
{A65BC954-07A1-40D9-BBB8-46349273D84E} = {A9207ADA-C81F-4112-BC31-35EA2A8362F7}
{0B24F998-9851-4F28-9A00-9388D8BE398C} = {2EC34A81-603E-458D-B1EA-B0BA814DF61D}
{5D231472-9941-4E90-950B-3709583E832A} = {4AB59492-513F-40B7-8253-0BC7ED0E8A71}
{D8FBFF88-111D-41F8-A958-7C6FB66FAC9F} = {2EC34A81-603E-458D-B1EA-B0BA814DF61D}
{8335B90F-6465-4882-9DA0-460BE0EA8DF4} = {2EC34A81-603E-458D-B1EA-B0BA814DF61D}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace AutoQueryable.Sample.EfCore.Contexts
{
public class AutoQueryableContext : DbContext
public class AutoQueryableDbContext : DbContext
{
public AutoQueryableContext(DbContextOptions<AutoQueryableContext> options)
public AutoQueryableDbContext(DbContextOptions<AutoQueryableDbContext> options)
: base(options)
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ProductController : ControllerBase
/// <returns></returns>
[AutoQueryable(UseBaseType = true)]
[HttpGet]
public IQueryable Get([FromServices] AutoQueryableContext context)
public IQueryable Get([FromServices] AutoQueryableDbContext context)
{
return context.Product;
}
Expand All @@ -36,7 +36,7 @@ public IQueryable Get([FromServices] AutoQueryableContext context)
/// <returns></returns>
[AutoQueryable]
[HttpGet("with_dto_projection")]
public IQueryable GetWithDtoProjection([FromServices] AutoQueryableContext context)
public IQueryable GetWithDtoProjection([FromServices] AutoQueryableDbContext context)
{
return context.Product.Select(p => new ProductDto
{
Expand All @@ -53,7 +53,7 @@ public IQueryable GetWithDtoProjection([FromServices] AutoQueryableContext conte
/// <param name="context"></param>
/// <returns></returns>
[HttpGet("disallow")]
public dynamic GetWithNotAllowedClauses([FromServices] AutoQueryableContext context)
public dynamic GetWithNotAllowedClauses([FromServices] AutoQueryableDbContext context)
{
return context.Product.AutoQueryable(Request.QueryString.Value,
new AutoQueryableProfile {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ProductOdataController
/// <returns></returns>
[AutoQueryable(ProviderType = ProviderType.OData)]
[HttpGet]
public IQueryable Get([FromServices] AutoQueryableContext context)
public IQueryable Get([FromServices] AutoQueryableDbContext context)
{
return context.Product;
}
Expand Down
6 changes: 3 additions & 3 deletions sample/AutoQueryable.Sample.EfCore/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ public void ConfigureServices(IServiceCollection services)
});

services.AddEntityFramework()
.AddDbContext<AutoQueryableContext>(options => options.UseInMemoryDatabase());
.AddDbContext<AutoQueryableDbContext>(options => options.UseInMemoryDatabase());
}

public void Configure(IApplicationBuilder app)
{
var context = app.ApplicationServices.GetService<AutoQueryableContext>();
var context = app.ApplicationServices.GetService<AutoQueryableDbContext>();
Seed(context);

app.UseMvc();
}

private void Seed(AutoQueryableContext context)
private void Seed(AutoQueryableDbContext context)
{
var fourthCategory = new ProductCategory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net &gt;=4.6.</Description>
<AssemblyTitle>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net &gt;=4.6.</AssemblyTitle>
<VersionPrefix>1.5.1</VersionPrefix>
<Version>1.5.1</Version>
<VersionPrefix>1.6.0</VersionPrefix>
<Version>1.6.0</Version>
<Authors>Thibaut Renoncourt</Authors>
<TargetFramework>net46</TargetFramework>
<AssemblyName>AutoQueryable.AspNet.Filter</AssemblyName>
Expand All @@ -16,12 +15,10 @@
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<ProjectReference Include="..\AutoQueryable\AutoQueryable.csproj" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.3" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
using System.Web.Http.Filters;
using AutoQueryable.Core.Enums;
using AutoQueryable.Core.Models;
using AutoQueryable.Core.Models.Abstractions;
using AutoQueryable.Helpers;

namespace AutoQueryable.AspNet.Filter.FilterAttributes
{
public class AutoQueryableAttribute : ActionFilterAttribute
public class AutoQueryableAttribute : ActionFilterAttribute, IFilterProfile
{
public string[] SelectableProperties { get; set; }

Expand All @@ -22,23 +23,31 @@ public class AutoQueryableAttribute : ActionFilterAttribute

public string[] UnGroupableProperties { get; set; }

public ClauseType? AllowedClauses { get; set; }
public ClauseType AllowedClauses { get; set; }

public ClauseType? DisAllowedClauses { get; set; }
public ClauseType DisAllowedClauses { get; set; }

public ConditionType? AllowedConditions { get; set; }
public ConditionType AllowedConditions { get; set; }

public ConditionType? DisAllowedConditions { get; set; }
public ConditionType DisAllowedConditions { get; set; }

public WrapperPartType? AllowedWrapperPartType { get; set; }
public WrapperPartType AllowedWrapperPartType { get; set; }

public WrapperPartType? DisAllowedWrapperPartType { get; set; }
public WrapperPartType DisAllowedWrapperPartType { get; set; }

public int? MaxToTake { get; set; }
public int MaxToTake { get; set; }

public int DefaultToTake { get; set; }

public int? MaxToSkip { get; set; }
public int MaxToSkip { get; set; }

public int? MaxDepth { get; set; }
public int MaxDepth { get; set; }

public string DefaultOrderBy { get; set; }

public string DefaultOrderByDesc { get; set; }

public bool UseBaseType { get; set; }


public override void OnActionExecuted(HttpActionExecutedContext context)
Expand All @@ -48,25 +57,11 @@ public override void OnActionExecuted(HttpActionExecutedContext context)
{
dynamic query = content.Value;
if (query == null) throw new Exception("Unable to retreive value of IQueryable from context result.");
Type entityType = query.GetType().GenericTypeArguments[0];

string queryString = context.Request.RequestUri.Query;
var result = QueryableHelper.GetAutoQuery(queryString, entityType, query, new AutoQueryableProfile {
SelectableProperties = SelectableProperties,
UnselectableProperties = UnselectableProperties,
SortableProperties = SortableProperties,
UnSortableProperties = UnSortableProperties,
GroupableProperties = GroupableProperties,
UnGroupableProperties = UnGroupableProperties,
AllowedClauses = AllowedClauses,
DisAllowedClauses = DisAllowedClauses,
AllowedConditions = AllowedConditions,
DisAllowedConditions = DisAllowedConditions,
AllowedWrapperPartType = AllowedWrapperPartType,
DisAllowedWrapperPartType = DisAllowedWrapperPartType,
MaxToTake = MaxToTake,
MaxToSkip = MaxToSkip,
MaxDepth = MaxDepth
});
AutoQueryableContext autoQueryableContext =
AutoQueryableContext.Create(query, queryString, AutoQueryableProfile.From(this));
var result = autoQueryableContext.GetAutoQuery();
context.Response.Content = new ObjectContent(result.GetType(), result, new JsonMediaTypeFormatter());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<Description>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net Core.</Description>
<AssemblyTitle>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net Core.</AssemblyTitle>
<VersionPrefix>1.5.1</VersionPrefix>
<Version>1.5.1</Version>
<VersionPrefix>1.6.0</VersionPrefix>
<Version>1.6.0</Version>
<Authors>Thibaut Renoncourt</Authors>
<TargetFramework>netstandard1.6</TargetFramework>
<AssemblyName>AutoQueryable.AspNetCore.Filter</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System;
using AutoQueryable.Core.Enums;
using AutoQueryable.Core.Models;
using AutoQueryable.Core.Models.Abstractions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using AutoQueryable.Helpers;

namespace AutoQueryable.AspNetCore.Filter.FilterAttributes
{
public class AutoQueryableAttribute : ActionFilterAttribute
public class AutoQueryableAttribute : ActionFilterAttribute, IFilterProfile
{
public string[] SelectableProperties { get; set; }

Expand All @@ -21,24 +22,30 @@ public class AutoQueryableAttribute : ActionFilterAttribute

public string[] UnGroupableProperties { get; set; }

public ClauseType? AllowedClauses { get; set; }
public ClauseType AllowedClauses { get; set; }

public ClauseType? DisAllowedClauses { get; set; }
public ClauseType DisAllowedClauses { get; set; }

public ConditionType? AllowedConditions { get; set; }
public ConditionType AllowedConditions { get; set; }

public ConditionType? DisAllowedConditions { get; set; }
public ConditionType DisAllowedConditions { get; set; }

public WrapperPartType? AllowedWrapperPartType { get; set; }
public WrapperPartType AllowedWrapperPartType { get; set; }

public WrapperPartType? DisAllowedWrapperPartType { get; set; }
public WrapperPartType DisAllowedWrapperPartType { get; set; }

public int? MaxToTake { get; set; }
public int MaxToTake { get; set; }

public int DefaultToTake { get; set; }

public int? MaxToSkip { get; set; }
public int MaxToSkip { get; set; }

public int? MaxDepth { get; set; }
public int MaxDepth { get; set; }

public string DefaultOrderBy { get; set; }

public string DefaultOrderByDesc { get; set; }

public ProviderType ProviderType { get; set; }

public bool UseBaseType { get; set; }
Expand All @@ -47,29 +54,11 @@ public override void OnActionExecuted(ActionExecutedContext context)
{
dynamic query = ((ObjectResult)context.Result).Value;
if (query == null) throw new Exception("Unable to retreive value of IQueryable from context result.");
Type entityType = query.GetType().GenericTypeArguments[0];

string queryString = context.HttpContext.Request.QueryString.HasValue ? context.HttpContext.Request.QueryString.Value : null;
context.Result = new OkObjectResult(QueryableHelper.GetAutoQuery(queryString, entityType, query, new AutoQueryableProfile
{
SelectableProperties = SelectableProperties,
UnselectableProperties = UnselectableProperties,
SortableProperties = SortableProperties,
UnSortableProperties = UnSortableProperties,
GroupableProperties = GroupableProperties,
UnGroupableProperties = UnGroupableProperties,
AllowedClauses = AllowedClauses,
DisAllowedClauses = DisAllowedClauses,
AllowedConditions = AllowedConditions,
DisAllowedConditions = DisAllowedConditions,
AllowedWrapperPartType = AllowedWrapperPartType,
DisAllowedWrapperPartType = DisAllowedWrapperPartType,
MaxToTake = MaxToTake,
MaxToSkip = MaxToSkip,
MaxDepth = MaxDepth,
ProviderType = ProviderType,
UseBaseType = UseBaseType
}));

string queryString = context.HttpContext.Request.QueryString.HasValue ? context.HttpContext.Request.QueryString.Value : null;;
AutoQueryableContext autoQueryableContext =
AutoQueryableContext.Create(query, queryString, AutoQueryableProfile.From(this));
context.Result = new OkObjectResult(autoQueryableContext.GetAutoQuery());
}
}
}
4 changes: 3 additions & 1 deletion src/AutoQueryable.Nancy.Filter/AfterPipelileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public static void AutoQueryable(this AfterPipeline afterPipeline, NancyContext
{
using (var writer = new StreamWriter(stream))
{
var result = QueryableHelper.GetAutoQuery(queryString, entityType, query, profile);
profile = profile ?? new AutoQueryableProfile();
var autoQueryableContext = AutoQueryableContext.Create(query, queryString, profile);
var result = autoQueryableContext.GetAutoQuery();
writer.Write(JsonConvert.SerializeObject(result));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<TargetFramework>netstandard1.6</TargetFramework>
<Description>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Nancy.</Description>
<Authors>Thibaut Renoncourt</Authors>
<VersionPrefix>1.5.1</VersionPrefix>
<Version>1.5.1</Version>
<VersionPrefix>1.6.0</VersionPrefix>
<Version>1.6.0</Version>
<PackageLicenseUrl>https://raw.githubusercontent.com/trenoncourt/AutoQueryable/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/trenoncourt/AutoQueryable</PackageProjectUrl>
<PackageTags>AutoQueryable;AutoQuery;OData;GraphQL</PackageTags>
Expand Down
12 changes: 4 additions & 8 deletions src/AutoQueryable/AutoQueryable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Description>AutoQueryable add auto querying functionality like OData with best url practices to Asp.Net Core.</Description>
<AssemblyTitle>AutoQueryable add auto querying functionality like OData with best url practices to Asp.Net Core.</AssemblyTitle>
<VersionPrefix>1.5.1</VersionPrefix>
<VersionPrefix>1.6.0</VersionPrefix>
<Authors>Thibaut Renoncourt</Authors>
<TargetFrameworks>netstandard1.3</TargetFrameworks>
<AssemblyName>AutoQueryable</AssemblyName>
Expand All @@ -14,18 +14,14 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<Version>1.5.1</Version>
<AssemblyVersion>1.5.1.0</AssemblyVersion>
<FileVersion>1.5.1.0</FileVersion>
<Version>1.6.0</Version>
<AssemblyVersion>1.6.0.0</AssemblyVersion>
<FileVersion>1.6.0.0</FileVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
<PackageReference Include="System.Linq.Queryable" Version="4.3.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AutoQueryable.Core\AutoQueryable.Core.csproj" />
<ProjectReference Include="..\AutoQueryable.Providers.OData\AutoQueryable.Providers.OData.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AutoQueryable.Providers.Default.Aliases
namespace AutoQueryable.Core.Aliases
{
public class ClauseAlias
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AutoQueryable.Providers.Default.Aliases
namespace AutoQueryable.Core.Aliases
{
public static class ConditionAlias
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AutoQueryable.Providers.Default.Aliases
namespace AutoQueryable.Core.Aliases
{
public class WrapperAlias
{
Expand Down
Loading

0 comments on commit 97202b4

Please sign in to comment.