Skip to content

Commit 295aead

Browse files
committed
1 parent b31d36f commit 295aead

File tree

8 files changed

+49
-21
lines changed

8 files changed

+49
-21
lines changed

src-console/ConsoleAppEF2.1.1/ConsoleApp_netcore2.1_EF2.1.1.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,4 @@
2424
<ProjectReference Include="..\..\src\Microsoft.EntityFrameworkCore.DynamicLinq\Microsoft.EntityFrameworkCore.DynamicLinq.csproj" />
2525
</ItemGroup>
2626

27-
<ItemGroup>
28-
<Folder Include="Database\" />
29-
</ItemGroup>
30-
3127
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.ComponentModel.DataAnnotations;
2+
3+
namespace ConsoleAppEF21.Database
4+
{
5+
public class Brand
6+
{
7+
[Key]
8+
public string BrandType { get; set; }
9+
10+
[Required]
11+
public string BrandName { get; set; }
12+
}
13+
}

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

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public class TestContext : DbContext
1010

1111
public virtual DbSet<Car> Cars { get; set; }
1212

13+
public virtual DbSet<Brand> Brands { get; set; }
14+
1315
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
1416
{
1517
optionsBuilder.UseLoggerFactory(MyLoggerFactory); // Warning: Do not create a new ILoggerFactory instance each time
@@ -21,6 +23,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
2123
protected override void OnModelCreating(ModelBuilder modelBuilder)
2224
{
2325
modelBuilder.Entity<Car>().HasKey(c => c.Key);
26+
modelBuilder.Entity<Brand>().HasKey(b => b.BrandType);
2427
}
2528

2629
// https://stackoverflow.com/questions/46212704/how-do-i-write-ef-functions-extension-method

src-console/ConsoleAppEF2.1/Program.cs

+28-2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ static void Main(string[] args)
6767
var config = ParsingConfig.DefaultEFCore21;
6868

6969
var context = new TestContext();
70+
//context.Database.EnsureDeleted();
71+
//context.Database.EnsureCreated();
7072
if (!context.Cars.Any())
7173
{
7274
context.Cars.Add(new Car { Brand = "Ford", Color = "Blue", Vin = "yes", Year = "2017" });
@@ -76,13 +78,37 @@ static void Main(string[] args)
7678
context.SaveChanges();
7779
}
7880

81+
if (!context.Brands.Any())
82+
{
83+
context.Brands.Add(new Brand { BrandType = "Ford", BrandName = "Fiesta" });
84+
context.Brands.Add(new Brand { BrandType = "Fiat", BrandName = "Panda" });
85+
context.Brands.Add(new Brand { BrandType = "Alfa", BrandName = "Romeo" });
86+
context.SaveChanges();
87+
}
88+
7989
//var g1 = context.Cars.GroupBy("new(Brand)").Select("new(Key.Brand as KeyValue1, it.Count() as CountValue1)").ToDynamicList();
8090
//Console.WriteLine("GroupBy @ local {0}", JsonConvert.SerializeObject(g1, Formatting.Indented));
8191

8292
//Console.WriteLine(new string('_', 80));
8393

84-
var g2 = context.Cars.GroupBy("new(Brand)", config).Select("new(Key.Brand as KeyValue2, it.Count() as CountValue2)").ToDynamicList();
85-
Console.WriteLine("GroupBy @ database {0}", JsonConvert.SerializeObject(g2, Formatting.Indented));
94+
//var g2 = context.Cars.GroupBy("new(Brand)", config).Select("new(Key.Brand as KeyValue2, it.Count() as CountValue2)").ToDynamicList();
95+
//Console.WriteLine("GroupBy @ database {0}", JsonConvert.SerializeObject(g2, Formatting.Indented));
96+
97+
var join1 = context.Cars.Join(
98+
context.Brands,
99+
c => c.Brand,
100+
b => b.BrandType,
101+
(c, b) => new { Brand = b, Car = c })
102+
.GroupBy(g => g.Car.Year);
103+
Console.WriteLine("join1 @ database {0}", JsonConvert.SerializeObject(join1, Formatting.Indented));
104+
105+
var join2 = context.Cars.Join(
106+
context.Brands,
107+
"it.Brand",
108+
"BrandType",
109+
"new(outer as Car, inner as Brand)")
110+
.GroupBy("Car.Year");
111+
Console.WriteLine("join2 @ database {0}", JsonConvert.SerializeObject(join2, Formatting.Indented));
86112

87113
//var carFirstOrDefault = context.Cars.Where(config, "Brand == \"Ford\"");
88114
//Console.WriteLine("carFirstOrDefault {0}", JsonConvert.SerializeObject(carFirstOrDefault, Formatting.Indented));

src/EntityFramework.DynamicLinq/EntityFramework.DynamicLinq.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<Description>Dynamic Linq extensions for EntityFramework which adds Async support</Description>
44
<AssemblyTitle>EntityFramework.DynamicLinq</AssemblyTitle>
5-
<VersionPrefix>1.0.8.16</VersionPrefix>
5+
<VersionPrefix>1.0.8.17</VersionPrefix>
66
<Authors>Stef Heyenrath</Authors>
77
<TargetFrameworks>net45;net46</TargetFrameworks>
88
<DefineConstants>EF</DefineConstants>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<Description>Dynamic Linq extensions for Microsoft.EntityFrameworkCore which adds Async support</Description>
44
<AssemblyTitle>Microsoft.EntityFrameworkCore.DynamicLinq</AssemblyTitle>
5-
<VersionPrefix>1.0.8.16</VersionPrefix>
5+
<VersionPrefix>1.0.8.17</VersionPrefix>
66
<Authors>Stef Heyenrath</Authors>
77
<TargetFrameworks>net451;net46;netstandard1.3;netstandard2.0;uap10.0</TargetFrameworks>
88
<DefineConstants>$(DefineConstants);EFCORE</DefineConstants>

src/System.Linq.Dynamic.Core/DynamicQueryableExtensions.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ public static IQueryable GroupJoin([NotNull] this IQueryable outer, [CanBeNull]
679679
Type outerType = outer.ElementType;
680680
Type innerType = inner.AsQueryable().ElementType;
681681

682-
bool createParameterCtor = outer.IsLinqToObjects();
682+
bool createParameterCtor = config?.EvaluateGroupByAtDatabase ?? outer.IsLinqToObjects();
683683
LambdaExpression outerSelectorLambda = DynamicExpressionParser.ParseLambda(config, createParameterCtor, outerType, null, outerKeySelector, args);
684684
LambdaExpression innerSelectorLambda = DynamicExpressionParser.ParseLambda(config, createParameterCtor, innerType, null, innerKeySelector, args);
685685

@@ -708,7 +708,6 @@ public static IQueryable GroupJoin([NotNull] this IQueryable outer, [NotNull] IE
708708
{
709709
return GroupJoin(outer, null, inner, outerKeySelector, innerKeySelector, resultSelector, args);
710710
}
711-
712711
#endregion
713712

714713
#region Join
@@ -736,7 +735,7 @@ public static IQueryable Join([NotNull] this IQueryable outer, [CanBeNull] Parsi
736735
Type outerType = outer.ElementType;
737736
Type innerType = inner.AsQueryable().ElementType;
738737

739-
bool createParameterCtor = outer.IsLinqToObjects();
738+
bool createParameterCtor = config?.EvaluateGroupByAtDatabase ?? outer.IsLinqToObjects();
740739
LambdaExpression outerSelectorLambda = DynamicExpressionParser.ParseLambda(config, createParameterCtor, outerType, null, outerKeySelector, args);
741740
LambdaExpression innerSelectorLambda = DynamicExpressionParser.ParseLambda(config, createParameterCtor, innerType, null, innerKeySelector, args);
742741

src/System.Linq.Dynamic.Core/System.Linq.Dynamic.Core.csproj

+1-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<Description>This is a .NETStandard/ .NET Core port of the the Microsoft assembly for the .Net 4.0 Dynamic language functionality.</Description>
44
<AssemblyTitle>System.Linq.Dynamic.Core</AssemblyTitle>
5-
<VersionPrefix>1.0.8.16</VersionPrefix>
5+
<VersionPrefix>1.0.8.17</VersionPrefix>
66
<Authors>Microsoft;Scott Guthrie;King Wilder;Nathan Arnott;Stef Heyenrath</Authors>
77
<TargetFrameworks>net35;net40;net45;net46;netstandard1.3;netstandard2.0;uap10.0</TargetFrameworks>
88
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -16,15 +16,6 @@
1616
<PackageLicenseUrl>https://github.com/StefH/System.Linq.Dynamic.Core/blob/master/licence.txt</PackageLicenseUrl>
1717
<RepositoryType>git</RepositoryType>
1818
<RepositoryUrl>https://github.com/StefH/System.Linq.Dynamic.Core</RepositoryUrl>
19-
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
20-
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
21-
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
22-
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
23-
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
24-
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
25-
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
26-
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
27-
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
2819
<DefaultLanguage>en-us</DefaultLanguage>
2920
<ProjectGuid>{D3804228-91F4-4502-9595-39584E510002}</ProjectGuid>
3021
<DebugType>full</DebugType>

0 commit comments

Comments
 (0)