Skip to content

Commit f0e91f5

Browse files
authored
Add EF 5 NuGet package (#470)
1 parent 7de6e98 commit f0e91f5

File tree

11 files changed

+262
-9
lines changed

11 files changed

+262
-9
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ There are several documentation resources:
3636
## Frameworks
3737
The following frameworks are supported:
3838
- net35, net40, net45, net46 and up
39-
- netstandard1.3 & netstandard2.0
40-
- uap10.0 (UAP 10.0.14393.0)
39+
- netstandard1.3, netstandard2.0 and netstandard2.1
40+
- netcoreapp3.1 and net5.0
41+
- uap10.0
4142

4243
## Fork details
4344
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.

System.Linq.Dynamic.Core.sln

+38
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestSLDC", "src-android\Tes
102102
EndProject
103103
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSLDC.Android", "src-android\TestSLDC.Android\TestSLDC.Android.csproj", "{85D70423-5800-41E9-B7D5-244AAF051A85}"
104104
EndProject
105+
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}"
106+
EndProject
107+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp_net5.0_EF5", "src-console\ConsoleAppEF5\ConsoleApp_net5.0_EF5.csproj", "{B3D1A89E-CE12-4A0D-B23E-8970D681C719}"
108+
EndProject
105109
Global
106110
GlobalSection(SolutionConfigurationPlatforms) = preSolution
107111
Debug|Any CPU = Debug|Any CPU
@@ -572,6 +576,38 @@ Global
572576
{85D70423-5800-41E9-B7D5-244AAF051A85}.Release|x86.ActiveCfg = Release|Any CPU
573577
{85D70423-5800-41E9-B7D5-244AAF051A85}.Release|x86.Build.0 = Release|Any CPU
574578
{85D70423-5800-41E9-B7D5-244AAF051A85}.Release|x86.Deploy.0 = Release|Any CPU
579+
{D3804228-91F4-4502-9595-39584E519901}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
580+
{D3804228-91F4-4502-9595-39584E519901}.Debug|Any CPU.Build.0 = Debug|Any CPU
581+
{D3804228-91F4-4502-9595-39584E519901}.Debug|ARM.ActiveCfg = Debug|Any CPU
582+
{D3804228-91F4-4502-9595-39584E519901}.Debug|ARM.Build.0 = Debug|Any CPU
583+
{D3804228-91F4-4502-9595-39584E519901}.Debug|x64.ActiveCfg = Debug|Any CPU
584+
{D3804228-91F4-4502-9595-39584E519901}.Debug|x64.Build.0 = Debug|Any CPU
585+
{D3804228-91F4-4502-9595-39584E519901}.Debug|x86.ActiveCfg = Debug|Any CPU
586+
{D3804228-91F4-4502-9595-39584E519901}.Debug|x86.Build.0 = Debug|Any CPU
587+
{D3804228-91F4-4502-9595-39584E519901}.Release|Any CPU.ActiveCfg = Release|Any CPU
588+
{D3804228-91F4-4502-9595-39584E519901}.Release|Any CPU.Build.0 = Release|Any CPU
589+
{D3804228-91F4-4502-9595-39584E519901}.Release|ARM.ActiveCfg = Release|Any CPU
590+
{D3804228-91F4-4502-9595-39584E519901}.Release|ARM.Build.0 = Release|Any CPU
591+
{D3804228-91F4-4502-9595-39584E519901}.Release|x64.ActiveCfg = Release|Any CPU
592+
{D3804228-91F4-4502-9595-39584E519901}.Release|x64.Build.0 = Release|Any CPU
593+
{D3804228-91F4-4502-9595-39584E519901}.Release|x86.ActiveCfg = Release|Any CPU
594+
{D3804228-91F4-4502-9595-39584E519901}.Release|x86.Build.0 = Release|Any CPU
595+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
596+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|Any CPU.Build.0 = Debug|Any CPU
597+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|ARM.ActiveCfg = Debug|Any CPU
598+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|ARM.Build.0 = Debug|Any CPU
599+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|x64.ActiveCfg = Debug|Any CPU
600+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|x64.Build.0 = Debug|Any CPU
601+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|x86.ActiveCfg = Debug|Any CPU
602+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Debug|x86.Build.0 = Debug|Any CPU
603+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|Any CPU.ActiveCfg = Release|Any CPU
604+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|Any CPU.Build.0 = Release|Any CPU
605+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|ARM.ActiveCfg = Release|Any CPU
606+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|ARM.Build.0 = Release|Any CPU
607+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|x64.ActiveCfg = Release|Any CPU
608+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|x64.Build.0 = Release|Any CPU
609+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|x86.ActiveCfg = Release|Any CPU
610+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719}.Release|x86.Build.0 = Release|Any CPU
575611
EndGlobalSection
576612
GlobalSection(SolutionProperties) = preSolution
577613
HideSolutionNode = FALSE
@@ -605,6 +641,8 @@ Global
605641
{7994FECC-965C-4A5D-8B0E-1A6EA769D4BE} = {DBD7D9B6-FCC7-4650-91AF-E6457573A68F}
606642
{EEF1D4FB-8DFD-4CC7-ABD9-808A7BB4ECD8} = {F5534C59-3A41-4A33-9E43-5CE0082A957F}
607643
{85D70423-5800-41E9-B7D5-244AAF051A85} = {F5534C59-3A41-4A33-9E43-5CE0082A957F}
644+
{D3804228-91F4-4502-9595-39584E519901} = {DBD7D9B6-FCC7-4650-91AF-E6457573A68F}
645+
{B3D1A89E-CE12-4A0D-B23E-8970D681C719} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62}
608646
EndGlobalSection
609647
GlobalSection(ExtensibilityGlobals) = postSolution
610648
SolutionGuid = {94C56722-194E-4B8B-BC23-B3F754E89A20}

src-console/ConsoleAppEF2.0/Database/TestContext.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace ConsoleAppEF2.Database
66
{
77
public class TestContext : DbContext
88
{
9-
#if EF3
9+
#if EF3 || EF5
1010
public static readonly ILoggerFactory MyLoggerFactory = LoggerFactory.Create(builder => {
1111
builder
1212
//.AddFilter("Default", LogLevel.Information)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net5.0</TargetFramework>
6+
<DefineConstants>EF5</DefineConstants>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<Compile Include="..\ConsoleAppEF2.0\Database\Brand.cs" Link="Database\Brand.cs" />
11+
<Compile Include="..\ConsoleAppEF2.0\Database\Car.cs" Link="Database\Car.cs" />
12+
<Compile Include="..\ConsoleAppEF2.0\Database\TestContext.cs" Link="Database\TestContext.cs" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0" />
19+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
20+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
21+
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<ProjectReference Include="..\..\src\Microsoft.EntityFrameworkCore.DynamicLinq.EFCore5\Microsoft.EntityFrameworkCore.DynamicLinq.EFCore5.csproj" />
26+
<ProjectReference Include="..\..\src\System.Linq.Dynamic.Core\System.Linq.Dynamic.Core.csproj" />
27+
</ItemGroup>
28+
29+
</Project>

src-console/ConsoleAppEF5/Program.cs

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
using System;
2+
using System.Linq;
3+
using System.Linq.Dynamic.Core;
4+
using System.Threading;
5+
using ConsoleAppEF2.Database;
6+
7+
namespace ConsoleAppEF5
8+
{
9+
class Program
10+
{
11+
static void Main(string[] args)
12+
{
13+
var users = new[] { new User { FirstName = "Doe" } }.AsQueryable();
14+
15+
var context = new TestContext();
16+
17+
//context.Database.EnsureDeleted();
18+
//context.Database.EnsureCreated();
19+
20+
var dateDeleted = new DateTime(2019, 2, 2);
21+
22+
var dateLastModified = new DateTime(2018, 1, 15);
23+
if (!context.Cars.Any())
24+
{
25+
context.Cars.Add(new Car { Brand = "Ford", Color = "Blue", Vin = "yes", Year = "2017", Extra = "e1", NullableInt = 1, DateLastModified = dateLastModified, DateDeleted = dateDeleted });
26+
context.Cars.Add(new Car { Brand = "Fiat", Color = "Red", Vin = "yes", Year = "2016", DateLastModified = dateLastModified.AddDays(1) });
27+
context.Cars.Add(new Car { Brand = "Alfa", Color = "Black", Vin = "no", Year = "1979", Extra = "e2", NullableInt = 2, DateLastModified = dateLastModified.AddDays(2) });
28+
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) }); ;
29+
context.Cars.Add(new Car { Brand = "Ford", Color = "Yellow", Vin = "no", Year = "2020", DateLastModified = dateLastModified });
30+
context.SaveChanges();
31+
}
32+
33+
context = new TestContext();
34+
var orderByYear = context.Cars.OrderBy("Year DESC").ToList();
35+
foreach (var x in orderByYear)
36+
{
37+
Console.WriteLine($"orderBy Year DESC = {x.Brand}");
38+
}
39+
40+
Thread.Sleep(500);
41+
42+
context = new TestContext();
43+
var orderBy3 = context.Cars.OrderBy("3 DESC").ToList();
44+
foreach (var x in orderBy3)
45+
{
46+
Console.WriteLine($"orderBy 3 DESC = {x.Brand}");
47+
}
48+
49+
var contains = context.Cars.Where("Brand.Contains(@0)", "a").ToDynamicList();
50+
51+
var npExtra1 = context.Cars.Select("np(Extra, \"no-extra\")").ToDynamicList();
52+
var npExtra2 = context.Cars.Select("np(Extra, string.Empty)").ToDynamicList();
53+
var npExtra3 = context.Cars.Any("np(Extra, string.Empty).ToUpper() == \"e1\"");
54+
55+
var npNullableInt = context.Cars.Select("np(NullableInt, 42)").ToDynamicList();
56+
57+
var selectNullableDateTime = context.Cars.FirstOrDefault(c => c.DateDeleted == dateDeleted);
58+
Console.WriteLine($"selectNullableDateTime.Key = {selectNullableDateTime.Key}");
59+
60+
var orderByNullableDateTimeResult = context.Cars.OrderBy(c => c.DateDeleted);
61+
foreach (var x in orderByNullableDateTimeResult)
62+
{
63+
Console.WriteLine($"orderByNullableDateTimeResult.Key,DateDeleted = {x.Key},{x.DateDeleted}");
64+
}
65+
66+
Console.WriteLine(new string('-', 80));
67+
68+
var orderByNullableDateTimeDynamicResult = context.Cars.OrderBy("DateDeleted");
69+
foreach (var x in orderByNullableDateTimeDynamicResult)
70+
{
71+
Console.WriteLine($"orderByNullableDateTimeDynamicResult.Key,DateDeleted = {x.Key},{x.DateDeleted}");
72+
}
73+
74+
Console.WriteLine(new string('-', 80));
75+
var orderByNullableDateTimeDynamicResultNew = context.Cars.Select("new (Color, DateDeleted)").OrderBy("DateDeleted desc");
76+
foreach (dynamic x in orderByNullableDateTimeDynamicResultNew)
77+
{
78+
Console.WriteLine($"orderByNullableDateTimeDynamicResult2.Color,DateDeleted = {x.Color},{x.DateDeleted}");
79+
}
80+
81+
var config = new ParsingConfig { AllowNewToEvaluateAnyType = true, ResolveTypesBySimpleName = false };
82+
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)");
83+
foreach (Car car in select)
84+
{
85+
Console.WriteLine($"{car.Key}");
86+
}
87+
88+
var resultDynamic = users.Any("c => np(c.FirstName, string.Empty).ToUpper() == \"DOE\"");
89+
Console.WriteLine(resultDynamic);
90+
91+
var users2 = users.Select<User>(config, "new User(it.FirstName as FirstName, 1 as Field)");
92+
foreach (User u in users2)
93+
{
94+
Console.WriteLine($"u.FirstName = {u.FirstName}, u.Field = {u.Field}");
95+
}
96+
97+
try
98+
{
99+
users.Select<User>(config, "new User(1 as FieldDoesNotExist)");
100+
}
101+
catch (Exception e)
102+
{
103+
Console.WriteLine(e);
104+
}
105+
106+
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)"))
107+
{
108+
Console.WriteLine($"x.FirstName = '{x.FirstName}' ; x.Str = '{x.Str == null}'");
109+
}
110+
}
111+
112+
public class User
113+
{
114+
public string FirstName { get; set; }
115+
public string LastName { get; set; }
116+
public string EmailAddress { get; set; }
117+
118+
public int Field;
119+
}
120+
}
121+
}

src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3/EFDynamicQueryableExtensions.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#if EFCORE
2+
using Microsoft.EntityFrameworkCore.Query;
23
using Microsoft.EntityFrameworkCore.Query.Internal;
34
#else
45
using System.Data.Entity.Infrastructure;
@@ -1036,9 +1037,6 @@ public static Task<dynamic> SumAsync([NotNull] this IQueryable source, Cancellat
10361037
= operatorMethodInfo.GetGenericArguments().Length == 2
10371038
? operatorMethodInfo.MakeGenericMethod(source.ElementType, typeof(TResult))
10381039
: operatorMethodInfo.MakeGenericMethod(source.ElementType);
1039-
1040-
1041-
10421040
#if EFCORE_3X
10431041
source = CastSource(source, operatorMethodInfo);
10441042
var optimized = OptimizeExpression(Expression.Call(null, operatorMethodInfo, new[] { source.Expression, expression }));

src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<DefineConstants>$(DefineConstants);EFCORE;EFCORE_3X;EFDYNAMICFUNCTIONS</DefineConstants>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1212
<AssemblyName>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyName>
13-
<AssemblyOriginatorKeyFile>Microsoft.EntityFrameworkCore.DynamicLinq.snk</AssemblyOriginatorKeyFile>
13+
<AssemblyOriginatorKeyFile>../Microsoft.EntityFrameworkCore.DynamicLinq.EFCore2/Microsoft.EntityFrameworkCore.DynamicLinq.snk</AssemblyOriginatorKeyFile>
1414
<SignAssembly>true</SignAssembly>
1515
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
1616
<PackageTags>system;linq;dynamic;entityframework;core;async</PackageTags>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
2+
<Import Project="../../version.xml" />
3+
4+
<PropertyGroup>
5+
<Version>5.2.$(PatchVersion)</Version>
6+
<Description>Dynamic Linq extensions for Microsoft.EntityFrameworkCore which adds Async support</Description>
7+
<AssemblyTitle>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyTitle>
8+
<Authors>ZZZ Projects;Stef Heyenrath</Authors>
9+
<TargetFrameworks>netstandard2.1</TargetFrameworks>
10+
<DefineConstants>$(DefineConstants);EFCORE;EFCORE_3X;EFDYNAMICFUNCTIONS</DefineConstants>
11+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
12+
<AssemblyName>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyName>
13+
<AssemblyOriginatorKeyFile>../Microsoft.EntityFrameworkCore.DynamicLinq.EFCore2/Microsoft.EntityFrameworkCore.DynamicLinq.snk</AssemblyOriginatorKeyFile>
14+
<SignAssembly>true</SignAssembly>
15+
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
16+
<PackageTags>system;linq;dynamic;entityframework;core;async</PackageTags>
17+
<PackageReleaseNotes>Bugfixes and new Features. For details see CHANGELOG.md</PackageReleaseNotes>
18+
<PackageProjectUrl>https://dynamic-linq.net/</PackageProjectUrl>
19+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
20+
<PackageIconUrl>https://zzzprojects.github.io/images/logo/logo-64.png</PackageIconUrl>
21+
<RepositoryType>git</RepositoryType>
22+
<RepositoryUrl>https://github.com/zzzprojects/System.Linq.Dynamic.Core</RepositoryUrl>
23+
<DefaultLanguage>en-us</DefaultLanguage>
24+
<ProjectGuid>{D3804228-91F4-4502-9595-39584E519901}</ProjectGuid>
25+
<DebugType>full</DebugType>
26+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
27+
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
28+
<Company>ZZZ Projects</Company>
29+
<Copyright>Copyright © ZZZ Projects</Copyright>
30+
</PropertyGroup>
31+
32+
<PropertyGroup Condition=" '$(buildType)' == 'azure-pipelines-ci' ">
33+
<TargetFrameworks>netstandard2.1</TargetFrameworks>
34+
</PropertyGroup>
35+
36+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
37+
<!--<IncludeSource>True</IncludeSource>
38+
<IncludeSymbols>True</IncludeSymbols>
39+
<PathMap>$(MSBuildProjectDirectory)=/</PathMap>-->
40+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
41+
</PropertyGroup>
42+
43+
<ItemGroup>
44+
<Compile Include="..\System.Linq.Dynamic.Core\Res.cs" />
45+
<Compile Include="..\System.Linq.Dynamic.Core\Compatibility\*.cs" />
46+
<Compile Include="..\System.Linq.Dynamic.Core\Extensions\*.cs" />
47+
<Compile Include="..\System.Linq.Dynamic.Core\Validation\*.cs" />
48+
<Compile Include="..\Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3\*.cs" />
49+
</ItemGroup>
50+
51+
<ItemGroup>
52+
<ProjectReference Include="..\System.Linq.Dynamic.Core\System.Linq.Dynamic.Core.csproj" />
53+
</ItemGroup>
54+
55+
<ItemGroup>
56+
<PackageReference Include="JetBrains.Annotations" Version="10.2.1" PrivateAssets="All" />
57+
58+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
59+
</ItemGroup>
60+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using System.Runtime.InteropServices;
2+
3+
[assembly: ComVisible(false)]
4+
#if !(WINDOWS_APP || NETSTANDARD2_1)
5+
[assembly: Guid("b467c675-c014-4b55-85b9-9578941d28c8")]
6+
#endif

version.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<PatchVersion>7-preview-02</PatchVersion>
3+
<PatchVersion>7</PatchVersion>
44
</PropertyGroup>
5-
</Project>
5+
</Project>

0 commit comments

Comments
 (0)