Skip to content

Commit

Permalink
Merge pull request #111 from linq2db/master
Browse files Browse the repository at this point in the history
Release 5.1.4
  • Loading branch information
sdanyliv authored Feb 15, 2021
2 parents 3ee892e + 2eac9fc commit 4ca3158
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Build/linq2db.Default.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>5.1.3</Version>
<Version>5.1.4</Version>

<Authors>Svyatoslav Danyliv, Igor Tkachev, Dmitry Lukashenko, Ilya Chudin</Authors>
<Product>Linq to DB</Product>
Expand Down
5 changes: 4 additions & 1 deletion Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ public T[] GetAttributes<T>(Type type, MemberInfo memberInfo, bool inherit = tru
.FirstOrDefault(v => CompareProperty(v.p, memberInfo))?.index ?? 0;
}

var isIdentity = prop.GetAnnotations()
.Any(a => a.Name.EndsWith(":ValueGenerationStrategy") && a.Value?.ToString() == "IdentityColumn");

var storeObjectId = GetStoreObjectIdentifier(et);

return new T[]{(T)(Attribute) new ColumnAttribute
Expand All @@ -167,7 +170,7 @@ public T[] GetAttributes<T>(Type type, MemberInfo memberInfo, bool inherit = tru
DbType = prop.GetColumnType(),
IsPrimaryKey = isPrimaryKey,
PrimaryKeyOrder = primaryKeyOrder,
IsIdentity = prop.ValueGenerated == ValueGenerated.OnAdd,
IsIdentity = isIdentity,
}};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
using System.Threading.Tasks;

using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Query.Internal;

using JetBrains.Annotations;
using LinqToDB.Expressions;

namespace LinqToDB.EntityFrameworkCore.Internal
Expand All @@ -24,7 +21,7 @@ namespace LinqToDB.EntityFrameworkCore.Internal
/// It may change or be removed without further notice.
/// </summary>
/// <typeparam name="T">Type of query element.</typeparam>
public class LinqToDBForEFQueryProvider<T> : IAsyncQueryProvider, IQueryProviderAsync, IQueryable<T>, System.Collections.Generic.IAsyncEnumerable<T>
public class LinqToDBForEFQueryProvider<T> : IAsyncQueryProvider, IQueryProviderAsync, IQueryable<T>, IAsyncEnumerable<T>
{
/// <summary>
/// Creates instance of adapter.
Expand Down Expand Up @@ -84,7 +81,7 @@ public TResult Execute<TResult>(Expression expression)
return QueryProvider.Execute<TResult>(expression);
}

private static MethodInfo _executeAsyncMethodInfo =
private static readonly MethodInfo _executeAsyncMethodInfo =
MemberHelper.MethodOf((IQueryProviderAsync p) => p.ExecuteAsync<int>(null!, default)).GetGenericMethodDefinition();

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,8 @@ public static bool IsQueryable(MethodCallExpression method, bool enumerable = tr
{
var type = method.Method.DeclaringType;

return type == typeof(Queryable) || (enumerable && type == typeof(Enumerable)) || type == typeof(LinqExtensions) ||
return type == typeof(Queryable) || (enumerable && type == typeof(Enumerable)) || type == typeof(LinqExtensions) ||
type == typeof(DataExtensions) || type == typeof(TableExtensions) ||
type == typeof(EntityFrameworkQueryableExtensions);
}

Expand Down Expand Up @@ -881,6 +882,16 @@ TransformInfo LocalTransform(Expression e)
break;
}

if (typeof(ITable<>).IsSameOrParentOf(methodCall.Type))
{
if (generic.Name == "ToLinqToDBTable")
{
return new TransformInfo(methodCall.Arguments[0], false, true);
}

break;
}

if (typeof(IQueryable<>).IsSameOrParentOf(methodCall.Type))
{
// Invoking function to evaluate EF's Subquery located in function
Expand Down
40 changes: 40 additions & 0 deletions Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ToolsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,46 @@ public void TestNullability([Values(true, false)] bool enableFilter)
}
}

[Test]
public void TestUpdate([Values(true, false)] bool enableFilter)
{
using (var ctx = CreateContext(enableFilter))
{
int? test = 1;
ctx.Employees.IgnoreQueryFilters().Where(e => e.EmployeeId == test).Update(x => new Employee
{
Address = x.Address

});
}
}

[Test]
public async Task TestUpdateAsync([Values(true, false)] bool enableFilter)
{
using (var ctx = CreateContext(enableFilter))
{
int? test = 1;
await ctx.Employees.IgnoreQueryFilters().Where(e => e.EmployeeId == test).UpdateAsync(x => new Employee
{
Address = x.Address

});
}
}

[Test]
public void TestCreateTempTable([Values(true, false)] bool enableFilter)
{
using (var ctx = CreateContext(enableFilter))
{
using var db = ctx.CreateLinqToDbContext();
using var temp = db.CreateTempTable(ctx.Employees, "#TestEmployees");

Assert.AreEqual(ctx.Employees.Count(), temp.Count());
}
}


[Test]
public void TestCommandTimeout()
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
variables:
solution: 'linq2db.EFCore.sln'
build_configuration: 'Release'
assemblyVersion: 5.1.3
nugetVersion: 5.1.3
assemblyVersion: 5.1.4
nugetVersion: 5.1.4
artifact_nugets: 'nugets'

# build on commits to important branches (master + release branches):
Expand Down

0 comments on commit 4ca3158

Please sign in to comment.