Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ There are several documentation resources:
## Frameworks
The following frameworks are supported:
- net35, net40, net45, net46 and up
- netstandard1.3 & netstandard2.0
- uap10.0 (UAP 10.0.14393.0)
- netstandard1.3, netstandard2.0 and netstandard2.1
- netcoreapp3.1 and net5.0
- uap10.0

## Fork details
This fork takes the basic library to a new level. Contains XML Documentation and examples on how to use it. Also adds unit testing to help ensure that it works properly.
Expand Down
38 changes: 38 additions & 0 deletions System.Linq.Dynamic.Core.sln
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestSLDC", "src-android\Tes
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSLDC.Android", "src-android\TestSLDC.Android\TestSLDC.Android.csproj", "{85D70423-5800-41E9-B7D5-244AAF051A85}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.EntityFrameworkCore.DynamicLinq.EFCore5", "src\Microsoft.EntityFrameworkCore.DynamicLinq.EFCore5\Microsoft.EntityFrameworkCore.DynamicLinq.EFCore5.csproj", "{D3804228-91F4-4502-9595-39584E519901}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp_net5.0_EF5", "src-console\ConsoleAppEF5\ConsoleApp_net5.0_EF5.csproj", "{B3D1A89E-CE12-4A0D-B23E-8970D681C719}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -572,6 +576,38 @@ Global
{85D70423-5800-41E9-B7D5-244AAF051A85}.Release|x86.ActiveCfg = Release|Any CPU
{85D70423-5800-41E9-B7D5-244AAF051A85}.Release|x86.Build.0 = Release|Any CPU
{85D70423-5800-41E9-B7D5-244AAF051A85}.Release|x86.Deploy.0 = Release|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Debug|ARM.ActiveCfg = Debug|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Debug|ARM.Build.0 = Debug|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Debug|x64.ActiveCfg = Debug|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Debug|x64.Build.0 = Debug|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Debug|x86.ActiveCfg = Debug|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Debug|x86.Build.0 = Debug|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Release|Any CPU.Build.0 = Release|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Release|ARM.ActiveCfg = Release|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Release|ARM.Build.0 = Release|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Release|x64.ActiveCfg = Release|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Release|x64.Build.0 = Release|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Release|x86.ActiveCfg = Release|Any CPU
{D3804228-91F4-4502-9595-39584E519901}.Release|x86.Build.0 = Release|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|ARM.ActiveCfg = Debug|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|ARM.Build.0 = Debug|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|x64.ActiveCfg = Debug|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|x64.Build.0 = Debug|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|x86.ActiveCfg = Debug|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|x86.Build.0 = Debug|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|Any CPU.Build.0 = Release|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|ARM.ActiveCfg = Release|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|ARM.Build.0 = Release|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|x64.ActiveCfg = Release|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|x64.Build.0 = Release|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|x86.ActiveCfg = Release|Any CPU
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -605,6 +641,8 @@ Global
{7994FECC-965C-4A5D-8B0E-1A6EA769D4BE} = {DBD7D9B6-FCC7-4650-91AF-E6457573A68F}
{EEF1D4FB-8DFD-4CC7-ABD9-808A7BB4ECD8} = {F5534C59-3A41-4A33-9E43-5CE0082A957F}
{85D70423-5800-41E9-B7D5-244AAF051A85} = {F5534C59-3A41-4A33-9E43-5CE0082A957F}
{D3804228-91F4-4502-9595-39584E519901} = {DBD7D9B6-FCC7-4650-91AF-E6457573A68F}
{B3D1A89E-CE12-4A0D-B23E-8970D681C719} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {94C56722-194E-4B8B-BC23-B3F754E89A20}
Expand Down
2 changes: 1 addition & 1 deletion src-console/ConsoleAppEF2.0/Database/TestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ConsoleAppEF2.Database
{
public class TestContext : DbContext
{
#if EF3
#if EF3 || EF5
public static readonly ILoggerFactory MyLoggerFactory = LoggerFactory.Create(builder => {
builder
//.AddFilter("Default", LogLevel.Information)
Expand Down
29 changes: 29 additions & 0 deletions src-console/ConsoleAppEF5/ConsoleApp_net5.0_EF5.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<DefineConstants>EF5</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\ConsoleAppEF2.0\Database\Brand.cs" Link="Database\Brand.cs" />
<Compile Include="..\ConsoleAppEF2.0\Database\Car.cs" Link="Database\Car.cs" />
<Compile Include="..\ConsoleAppEF2.0\Database\TestContext.cs" Link="Database\TestContext.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.EntityFrameworkCore.DynamicLinq.EFCore5\Microsoft.EntityFrameworkCore.DynamicLinq.EFCore5.csproj" />
<ProjectReference Include="..\..\src\System.Linq.Dynamic.Core\System.Linq.Dynamic.Core.csproj" />
</ItemGroup>

</Project>
121 changes: 121 additions & 0 deletions src-console/ConsoleAppEF5/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
using System;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using ConsoleAppEF2.Database;

namespace ConsoleAppEF5
{
class Program
{
static void Main(string[] args)
{
var users = new[] { new User { FirstName = "Doe" } }.AsQueryable();

var context = new TestContext();

//context.Database.EnsureDeleted();
//context.Database.EnsureCreated();

var dateDeleted = new DateTime(2019, 2, 2);

var dateLastModified = new DateTime(2018, 1, 15);
if (!context.Cars.Any())
{
context.Cars.Add(new Car { Brand = "Ford", Color = "Blue", Vin = "yes", Year = "2017", Extra = "e1", NullableInt = 1, DateLastModified = dateLastModified, DateDeleted = dateDeleted });
context.Cars.Add(new Car { Brand = "Fiat", Color = "Red", Vin = "yes", Year = "2016", DateLastModified = dateLastModified.AddDays(1) });
context.Cars.Add(new Car { Brand = "Alfa", Color = "Black", Vin = "no", Year = "1979", Extra = "e2", NullableInt = 2, DateLastModified = dateLastModified.AddDays(2) });
context.Cars.Add(new Car { Brand = "Alfa", Color = "Black", Vin = "a%bc", Year = "1979", Extra = "e3", NullableInt = 3, DateLastModified = dateLastModified.AddDays(3), DateDeleted = dateDeleted.AddDays(1) }); ;
context.Cars.Add(new Car { Brand = "Ford", Color = "Yellow", Vin = "no", Year = "2020", DateLastModified = dateLastModified });
context.SaveChanges();
}

context = new TestContext();
var orderByYear = context.Cars.OrderBy("Year DESC").ToList();
foreach (var x in orderByYear)
{
Console.WriteLine($"orderBy Year DESC = {x.Brand}");
}

Thread.Sleep(500);

context = new TestContext();
var orderBy3 = context.Cars.OrderBy("3 DESC").ToList();
foreach (var x in orderBy3)
{
Console.WriteLine($"orderBy 3 DESC = {x.Brand}");
}

var contains = context.Cars.Where("Brand.Contains(@0)", "a").ToDynamicList();

var npExtra1 = context.Cars.Select("np(Extra, \"no-extra\")").ToDynamicList();
var npExtra2 = context.Cars.Select("np(Extra, string.Empty)").ToDynamicList();
var npExtra3 = context.Cars.Any("np(Extra, string.Empty).ToUpper() == \"e1\"");

var npNullableInt = context.Cars.Select("np(NullableInt, 42)").ToDynamicList();

var selectNullableDateTime = context.Cars.FirstOrDefault(c => c.DateDeleted == dateDeleted);
Console.WriteLine($"selectNullableDateTime.Key = {selectNullableDateTime.Key}");

var orderByNullableDateTimeResult = context.Cars.OrderBy(c => c.DateDeleted);
foreach (var x in orderByNullableDateTimeResult)
{
Console.WriteLine($"orderByNullableDateTimeResult.Key,DateDeleted = {x.Key},{x.DateDeleted}");
}

Console.WriteLine(new string('-', 80));

var orderByNullableDateTimeDynamicResult = context.Cars.OrderBy("DateDeleted");
foreach (var x in orderByNullableDateTimeDynamicResult)
{
Console.WriteLine($"orderByNullableDateTimeDynamicResult.Key,DateDeleted = {x.Key},{x.DateDeleted}");
}

Console.WriteLine(new string('-', 80));
var orderByNullableDateTimeDynamicResultNew = context.Cars.Select("new (Color, DateDeleted)").OrderBy("DateDeleted desc");
foreach (dynamic x in orderByNullableDateTimeDynamicResultNew)
{
Console.WriteLine($"orderByNullableDateTimeDynamicResult2.Color,DateDeleted = {x.Color},{x.DateDeleted}");
}

var config = new ParsingConfig { AllowNewToEvaluateAnyType = true, ResolveTypesBySimpleName = false };
var select = context.Cars.Select<Car>(config, $"new {typeof(Car).FullName}(it.Key as Key, \"?\" as Brand, string(null) as Color, string(\"e\") as Extra)");
foreach (Car car in select)
{
Console.WriteLine($"{car.Key}");
}

var resultDynamic = users.Any("c => np(c.FirstName, string.Empty).ToUpper() == \"DOE\"");
Console.WriteLine(resultDynamic);

var users2 = users.Select<User>(config, "new User(it.FirstName as FirstName, 1 as Field)");
foreach (User u in users2)
{
Console.WriteLine($"u.FirstName = {u.FirstName}, u.Field = {u.Field}");
}

try
{
users.Select<User>(config, "new User(1 as FieldDoesNotExist)");
}
catch (Exception e)
{
Console.WriteLine(e);
}

foreach (dynamic x in users.Select("new (FirstName, string(\"a\") as StrA, string('c') as StrCh, string(\"\") as StrEmpty1, string('\0') as StrEmpty2, string(null) as StrNull)"))
{
Console.WriteLine($"x.FirstName = '{x.FirstName}' ; x.Str = '{x.Str == null}'");
}
}

public class User
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string EmailAddress { get; set; }

public int Field;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#if EFCORE
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Query.Internal;
#else
using System.Data.Entity.Infrastructure;
Expand Down Expand Up @@ -1036,9 +1037,6 @@ public static Task<dynamic> SumAsync([NotNull] this IQueryable source, Cancellat
= operatorMethodInfo.GetGenericArguments().Length == 2
? operatorMethodInfo.MakeGenericMethod(source.ElementType, typeof(TResult))
: operatorMethodInfo.MakeGenericMethod(source.ElementType);



#if EFCORE_3X
source = CastSource(source, operatorMethodInfo);
var optimized = OptimizeExpression(Expression.Call(null, operatorMethodInfo, new[] { source.Expression, expression }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<DefineConstants>$(DefineConstants);EFCORE;EFCORE_3X;EFDYNAMICFUNCTIONS</DefineConstants>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyName>
<AssemblyOriginatorKeyFile>Microsoft.EntityFrameworkCore.DynamicLinq.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>../Microsoft.EntityFrameworkCore.DynamicLinq.EFCore2/Microsoft.EntityFrameworkCore.DynamicLinq.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageTags>system;linq;dynamic;entityframework;core;async</PackageTags>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<Import Project="../../version.xml" />

<PropertyGroup>
<Version>5.2.$(PatchVersion)</Version>
<Description>Dynamic Linq extensions for Microsoft.EntityFrameworkCore which adds Async support</Description>
<AssemblyTitle>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyTitle>
<Authors>ZZZ Projects;Stef Heyenrath</Authors>
<TargetFrameworks>netstandard2.1</TargetFrameworks>
<DefineConstants>$(DefineConstants);EFCORE;EFCORE_3X;EFDYNAMICFUNCTIONS</DefineConstants>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyName>
<AssemblyOriginatorKeyFile>../Microsoft.EntityFrameworkCore.DynamicLinq.EFCore2/Microsoft.EntityFrameworkCore.DynamicLinq.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageTags>system;linq;dynamic;entityframework;core;async</PackageTags>
<PackageReleaseNotes>Bugfixes and new Features. For details see CHANGELOG.md</PackageReleaseNotes>
<PackageProjectUrl>https://dynamic-linq.net/</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageIconUrl>https://zzzprojects.github.io/images/logo/logo-64.png</PackageIconUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/zzzprojects/System.Linq.Dynamic.Core</RepositoryUrl>
<DefaultLanguage>en-us</DefaultLanguage>
<ProjectGuid>{D3804228-91F4-4502-9595-39584E519901}</ProjectGuid>
<DebugType>full</DebugType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<Company>ZZZ Projects</Company>
<Copyright>Copyright © ZZZ Projects</Copyright>
</PropertyGroup>

<PropertyGroup Condition=" '$(buildType)' == 'azure-pipelines-ci' ">
<TargetFrameworks>netstandard2.1</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<!--<IncludeSource>True</IncludeSource>
<IncludeSymbols>True</IncludeSymbols>
<PathMap>$(MSBuildProjectDirectory)=/</PathMap>-->
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\System.Linq.Dynamic.Core\Res.cs" />
<Compile Include="..\System.Linq.Dynamic.Core\Compatibility\*.cs" />
<Compile Include="..\System.Linq.Dynamic.Core\Extensions\*.cs" />
<Compile Include="..\System.Linq.Dynamic.Core\Validation\*.cs" />
<Compile Include="..\Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3\*.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\System.Linq.Dynamic.Core\System.Linq.Dynamic.Core.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="10.2.1" PrivateAssets="All" />

<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using System.Runtime.InteropServices;

[assembly: ComVisible(false)]
#if !(WINDOWS_APP || NETSTANDARD2_1)
[assembly: Guid("b467c675-c014-4b55-85b9-9578941d28c8")]
#endif
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<PatchVersion>7-preview-02</PatchVersion>
<PatchVersion>7</PatchVersion>
</PropertyGroup>
</Project>
</Project>