Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit 1513017

Browse files
committed
Merge branch 'master' into release
2 parents 77c0ece + 35966d9 commit 1513017

18 files changed

+34770
-11
lines changed

Source/LinqToDB.EntityFrameworkCore/Internal/EFCoreExpressionAttribute.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public EFCoreExpressionAttribute(string expression) : base(expression)
1313
{
1414
}
1515

16-
public override ISqlExpression GetExpression(MappingSchema mapping, SelectQuery query, Expression expression, Func<Expression, ISqlExpression> converter)
16+
public override ISqlExpression GetExpression(IDataContext dataContext, SelectQuery query,
17+
Expression expression, Func<Expression, ISqlExpression> converter)
1718
{
1819
var knownExpressions = new List<Expression>();
1920
if (expression.NodeType == ExpressionType.Call)

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ protected virtual IDataProvider CreateLinqToDbDataProvider(EFProviderInfo provid
141141
case ProviderName.SqlServer:
142142
return CreateSqlServerProvider(SqlServerDefaultVersion, connectionInfo.ConnectionString);
143143
case ProviderName.MySql:
144-
return new MySqlDataProvider();
144+
case ProviderName.MySqlConnector:
145+
return new MySqlDataProvider(provInfo.ProviderName);
145146
case ProviderName.PostgreSQL:
146147
return CreatePostgreSqlProvider(PostgreSqlDefaultVersion, connectionInfo.ConnectionString);
147148
case ProviderName.SQLite:
@@ -174,8 +175,12 @@ protected virtual LinqToDBProviderInfo GetLinqToDbProviderInfo(DatabaseFacade da
174175
return new LinqToDBProviderInfo { ProviderName = ProviderName.SqlServer };
175176

176177
case "Pomelo.EntityFrameworkCore.MySql":
177-
case "MySql.Data.EntityFrameworkCore":
178178
case "Devart.Data.MySql.EFCore":
179+
{
180+
return new LinqToDBProviderInfo { ProviderName = ProviderName.MySqlConnector };
181+
}
182+
183+
case "MySql.Data.EntityFrameworkCore":
179184
{
180185
return new LinqToDBProviderInfo { ProviderName = ProviderName.MySql };
181186
}
@@ -245,6 +250,7 @@ protected virtual LinqToDBProviderInfo GetLinqToDbProviderInfo(RelationalOption
245250
switch (extensions.GetType().Name)
246251
{
247252
case "MySqlOptionsExtension":
253+
return new LinqToDBProviderInfo { ProviderName = ProviderName.MySqlConnector };
248254
case "MySQLOptionsExtension":
249255
return new LinqToDBProviderInfo { ProviderName = ProviderName.MySql };
250256
case "NpgsqlOptionsExtension":

Source/LinqToDB.EntityFrameworkCore/linq2db.EntityFrameworkCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="linq2db" Version="2.6.4" />
12+
<PackageReference Include="linq2db" Version="2.7.0" />
1313
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.1" />
1414
</ItemGroup>
1515

Tests/LinqToDB.EntityFrameworkCore.Tests/LinqToDB.EntityFrameworkCore.Tests.csproj

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@
44
<TargetFrameworks>net462</TargetFrameworks>
55
</PropertyGroup>
66

7+
<ItemGroup>
8+
<Compile Remove="Models\UniversalEntities\**" />
9+
<EmbeddedResource Remove="Models\UniversalEntities\**" />
10+
<None Remove="Models\UniversalEntities\**" />
11+
</ItemGroup>
12+
713
<ItemGroup>
814
<PackageReference Include="JetBrains.DotMemoryUnit" Version="3.0.20171219.105559" />
9-
<PackageReference Include="linq2db" Version="2.6.4" />
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.2.1" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.1" />
15+
<PackageReference Include="linq2db" Version="2.7.0" />
16+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.2.4" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
1218
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
19+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
1420
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.2.0" />
1521
<PackageReference Include="NUnit" Version="3.11.0" />
16-
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.4" />
22+
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
1723
</ItemGroup>
1824

1925
<ItemGroup>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.Collections.Generic;
5+
using System.ComponentModel.DataAnnotations.Schema;
6+
using Microsoft.EntityFrameworkCore.Infrastructure;
7+
8+
// ReSharper disable UnusedParameter.Local
9+
10+
namespace Microsoft.EntityFrameworkCore.TestModels.Northwind
11+
{
12+
public class Customer
13+
{
14+
public Customer()
15+
{
16+
}
17+
18+
// Custom ctor binding
19+
public Customer(DbContext context, ILazyLoader lazyLoader, string customerID)
20+
{
21+
CustomerID = customerID;
22+
}
23+
24+
public string CustomerID { get; set; }
25+
public string CompanyName { get; set; }
26+
public string ContactName { get; set; }
27+
public string ContactTitle { get; set; }
28+
public string Address { get; set; }
29+
public string City { get; set; }
30+
public string Region { get; set; }
31+
public string PostalCode { get; set; }
32+
public string Country { get; set; }
33+
public string Phone { get; set; }
34+
public string Fax { get; set; }
35+
36+
public virtual List<Order> Orders { get; set; }
37+
38+
public NorthwindContext Context { get; set; }
39+
40+
[NotMapped]
41+
public bool IsLondon => City == "London";
42+
43+
protected bool Equals(Customer other) => string.Equals(CustomerID, other.CustomerID);
44+
45+
public override bool Equals(object obj)
46+
{
47+
if (obj is null)
48+
{
49+
return false;
50+
}
51+
52+
if (ReferenceEquals(this, obj))
53+
{
54+
return true;
55+
}
56+
57+
return obj.GetType() == GetType()
58+
&& Equals((Customer)obj);
59+
}
60+
61+
public static bool operator ==(Customer left, Customer right) => Equals(left, right);
62+
63+
public static bool operator !=(Customer left, Customer right) => !Equals(left, right);
64+
65+
public override int GetHashCode() => CustomerID.GetHashCode();
66+
67+
public override string ToString() => "Customer " + CustomerID;
68+
}
69+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
namespace Microsoft.EntityFrameworkCore.TestModels.Northwind
5+
{
6+
public class CustomerQuery
7+
{
8+
public string CompanyName { get; set; }
9+
public int OrderCount { get; set; }
10+
public string SearchTerm { get; set; }
11+
}
12+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.ComponentModel.DataAnnotations.Schema;
5+
6+
namespace Microsoft.EntityFrameworkCore.TestModels.Northwind
7+
{
8+
public class CustomerView
9+
{
10+
public string CompanyName { get; set; }
11+
public string ContactName { get; set; }
12+
public string ContactTitle { get; set; }
13+
public string Address { get; set; }
14+
public string City { get; set; }
15+
16+
[NotMapped]
17+
public bool IsLondon => City == "London";
18+
19+
protected bool Equals(CustomerView other)
20+
=> string.Equals(CompanyName, other.CompanyName);
21+
22+
public override bool Equals(object obj)
23+
{
24+
if (obj is null)
25+
{
26+
return false;
27+
}
28+
29+
if (ReferenceEquals(this, obj))
30+
{
31+
return true;
32+
}
33+
34+
return obj.GetType() == GetType()
35+
&& Equals((CustomerView)obj);
36+
}
37+
38+
public static bool operator ==(CustomerView left, CustomerView right)
39+
=> Equals(left, right);
40+
41+
public static bool operator !=(CustomerView left, CustomerView right)
42+
=> !Equals(left, right);
43+
44+
public override int GetHashCode()
45+
// ReSharper disable once NonReadonlyMemberInGetHashCode
46+
=> CompanyName.GetHashCode();
47+
48+
public override string ToString()
49+
=> "CustomerView " + CompanyName;
50+
}
51+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
6+
namespace Microsoft.EntityFrameworkCore.TestModels.Northwind
7+
{
8+
public class Employee
9+
{
10+
#if Test20
11+
public int EmployeeID { get; set; }
12+
#else
13+
public uint EmployeeID { get; set; }
14+
#endif
15+
public string LastName { get; set; }
16+
public string FirstName { get; set; }
17+
public string Title { get; set; }
18+
public string TitleOfCourtesy { get; set; }
19+
public DateTime? BirthDate { get; set; }
20+
public DateTime? HireDate { get; set; }
21+
public string Address { get; set; }
22+
public string City { get; set; }
23+
public string Region { get; set; }
24+
public string PostalCode { get; set; }
25+
public string Country { get; set; }
26+
public string HomePhone { get; set; }
27+
public string Extension { get; set; }
28+
public byte[] Photo { get; set; }
29+
public string Notes { get; set; }
30+
#if Test20
31+
public int? ReportsTo { get; set; }
32+
#else
33+
public uint? ReportsTo { get; set; }
34+
#endif
35+
public string PhotoPath { get; set; }
36+
37+
public Employee Manager { get; set; }
38+
39+
protected bool Equals(Employee other) => EmployeeID == other.EmployeeID;
40+
41+
public override bool Equals(object obj)
42+
{
43+
if (obj is null)
44+
{
45+
return false;
46+
}
47+
48+
if (ReferenceEquals(this, obj))
49+
{
50+
return true;
51+
}
52+
53+
return obj.GetType() == GetType()
54+
&& Equals((Employee)obj);
55+
}
56+
57+
public override int GetHashCode() => EmployeeID.GetHashCode();
58+
59+
public override string ToString() => "Employee " + EmployeeID;
60+
}
61+
}

0 commit comments

Comments
 (0)