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

Commit 74303fb

Browse files
committed
Backport changes from version 5.x
1 parent 87c913b commit 74303fb

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ public T[] GetAttributes<T>(Type type, MemberInfo memberInfo, bool inherit = tru
149149
.FirstOrDefault(v => CompareProperty(v.p, memberInfo))?.index ?? 0;
150150
}
151151

152+
var isIdentity = prop.GetAnnotations()
153+
.Any(a => a.Name.EndsWith(":ValueGenerationStrategy") && a.Value?.ToString() == "IdentityColumn");
154+
152155
return new T[]{(T)(Attribute) new ColumnAttribute
153156
{
154157
Name = prop.GetColumnName(),
@@ -157,7 +160,7 @@ public T[] GetAttributes<T>(Type type, MemberInfo memberInfo, bool inherit = tru
157160
DbType = prop.GetColumnType(),
158161
IsPrimaryKey = isPrimaryKey,
159162
PrimaryKeyOrder = primaryKeyOrder,
160-
IsIdentity = prop.ValueGenerated == ValueGenerated.OnAdd,
163+
IsIdentity = isIdentity,
161164
}};
162165
}
163166
}

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,8 @@ public static bool IsQueryable(MethodCallExpression method, bool enumerable = tr
620620
{
621621
var type = method.Method.DeclaringType;
622622

623-
return type == typeof(Queryable) || (enumerable && type == typeof(Enumerable)) || type == typeof(LinqExtensions) ||
623+
return type == typeof(Queryable) || (enumerable && type == typeof(Enumerable)) || type == typeof(LinqExtensions) ||
624+
type == typeof(DataExtensions) || type == typeof(TableExtensions) ||
624625
type == typeof(EntityFrameworkQueryableExtensions);
625626
}
626627

@@ -879,6 +880,16 @@ TransformInfo LocalTransform(Expression e)
879880
break;
880881
}
881882

883+
if (typeof(ITable<>).IsSameOrParentOf(methodCall.Type))
884+
{
885+
if (generic.Name == "ToLinqToDBTable")
886+
{
887+
return new TransformInfo(methodCall.Arguments[0], false, true);
888+
}
889+
890+
break;
891+
}
892+
882893
if (generic == FromSqlOnQueryableMethodInfo)
883894
{
884895
//convert the arguments from the FromSqlOnQueryable method from EF, to a L2DB FromSql call

Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ToolsTests.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ public void TestNullability([Values(true, false)] bool enableFilter)
768768
}
769769
}
770770

771-
772771
[Test]
773772
public void TestUpdate([Values(true, false)] bool enableFilter)
774773
{
@@ -797,6 +796,18 @@ public async Task TestUpdateAsync([Values(true, false)] bool enableFilter)
797796
}
798797
}
799798

799+
[Test]
800+
public void TestCreateTempTable([Values(true, false)] bool enableFilter)
801+
{
802+
using (var ctx = CreateContext(enableFilter))
803+
{
804+
using var db = ctx.CreateLinqToDbContext();
805+
using var temp = db.CreateTempTable(ctx.Employees, "#TestEmployees");
806+
807+
Assert.AreEqual(ctx.Employees.Count(), temp.Count());
808+
}
809+
}
810+
800811

801812
[Test]
802813
public void TestCommandTimeout()

0 commit comments

Comments
 (0)