changed to .net standard.

This commit is contained in:
David Lebée
2018-02-20 21:21:23 -06:00
parent f6ce5a45af
commit 8396e24305
11 changed files with 53 additions and 214 deletions
+6
View File
@@ -32,6 +32,12 @@ namespace PoweredSoft.DynamicLinq
All
}
public enum QuerySortDirection
{
Ascending,
Descending
}
internal static class Constants
{
internal static readonly MethodInfo ContainsMethod = typeof(string).GetMethod("Contains");
@@ -2,7 +2,6 @@
using PoweredSoft.DynamicLinq.Helpers;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
@@ -29,10 +28,10 @@ namespace PoweredSoft.DynamicLinq.Extensions
return ret;
}
public static IQueryable<T> Sort<T>(this IQueryable<T> query, string path, SortOrder sortOrder, bool appendSort)
public static IQueryable<T> Sort<T>(this IQueryable<T> query, string path, QuerySortDirection sortDirection, bool appendSort)
{
var qb = new QueryBuilder<T>(query);
qb.Sort(path, sortOrder, appendSort);
qb.Sort(path, sortDirection, appendSort);
var ret = qb.Build();
return ret;
}
@@ -1,7 +1,6 @@
using PoweredSoft.DynamicLinq.Helpers;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
@@ -38,7 +37,7 @@ namespace PoweredSoft.DynamicLinq.Fluent
{
Sorts.ForEach(sort =>
{
query = QueryableHelpers.CreateSortExpression(query, sort.Path, sort.SortOrder, sort.AppendSort);
query = QueryableHelpers.CreateSortExpression(query, sort.Path, sort.sortDirection, sort.AppendSort);
});
return query;
@@ -1,7 +1,6 @@
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -39,12 +38,12 @@ namespace PoweredSoft.DynamicLinq.Fluent
return this;
}
public virtual QueryBuilderBase Sort(string path, SortOrder sortOrder, bool appendSort)
public virtual QueryBuilderBase Sort(string path, QuerySortDirection sortDirection, bool appendSort)
{
Sorts.Add(new QueryBuilderSort
{
Path = path,
SortOrder = sortOrder,
sortDirection = sortDirection,
AppendSort = appendSort
});
return this;
@@ -91,7 +90,7 @@ namespace PoweredSoft.DynamicLinq.Fluent
Sorts.Add(new QueryBuilderSort
{
Path = path,
SortOrder = SortOrder.Ascending,
sortDirection = QuerySortDirection.Ascending,
AppendSort = false
});
return this;
@@ -103,7 +102,7 @@ namespace PoweredSoft.DynamicLinq.Fluent
Sorts.Add(new QueryBuilderSort
{
Path = path,
SortOrder = SortOrder.Descending,
sortDirection = QuerySortDirection.Descending,
AppendSort = false
});
return this;
@@ -114,7 +113,7 @@ namespace PoweredSoft.DynamicLinq.Fluent
Sorts.Add(new QueryBuilderSort
{
Path = path,
SortOrder = SortOrder.Ascending,
sortDirection = QuerySortDirection.Ascending,
AppendSort = true
});
return this;
@@ -125,7 +124,7 @@ namespace PoweredSoft.DynamicLinq.Fluent
Sorts.Add(new QueryBuilderSort
{
Path = path,
SortOrder = SortOrder.Descending,
sortDirection = QuerySortDirection.Descending,
AppendSort = true
});
return this;
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -11,7 +10,7 @@ namespace PoweredSoft.DynamicLinq.Fluent
{
public string Path { get; set; }
public SortOrder SortOrder { get; set; } = SortOrder.Ascending;
public QuerySortDirection sortDirection { get; set; } = QuerySortDirection.Ascending;
public bool AppendSort { get; set; }
}
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
@@ -96,13 +95,13 @@ namespace PoweredSoft.DynamicLinq.Helpers
throw new NotSupportedException($"{convertStrategy} supplied is not recognized");
}
public static IQueryable<T> CreateSortExpression<T>(IQueryable<T> query, string sortPath, SortOrder sortOrder, bool appendSort = true)
public static IQueryable<T> CreateSortExpression<T>(IQueryable<T> query, string sortPath, QuerySortDirection sortDirection, bool appendSort = true)
{
var parameter = Expression.Parameter(typeof(T), "t");
var member = QueryableHelpers.ResolvePathForExpression(parameter, sortPath);
string sortCommand = null;
if (sortOrder == SortOrder.Descending)
if (sortDirection == QuerySortDirection.Descending)
sortCommand = appendSort == false ? "OrderByDescending" : "ThenByDescending";
else
sortCommand = appendSort == false ? "OrderBy" : "ThenBy";
@@ -1,56 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2ABC5A60-B549-4ECD-BEF4-31CA7BA4EF06}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PoweredSoft.DynamicLinq</RootNamespace>
<AssemblyName>PoweredSoft.DynamicLinq</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Constants.cs" />
<Compile Include="Extensions\QueryableExtensions.cs" />
<Compile Include="Fluent\QueryBuilderBase.cs" />
<Compile Include="Fluent\QueryBuilderSort.cs" />
<Compile Include="Helpers\QueryableHelpers.cs" />
<Compile Include="Helpers\TypeHelpers.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Fluent\QueryBuilder.cs" />
<Compile Include="Fluent\QueryBuilderFilter.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PoweredSoft.DynamicLinq")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PoweredSoft.DynamicLinq")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2abc5a60-b549-4ecd-bef4-31ca7ba4ef06")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]