diff --git a/Directory.Build.props b/Directory.Build.props
index cd0f7dd..932ca59 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -23,11 +23,15 @@
- net6.0
+ net7.0;net6.0
6.0.0
6.0.0
$(EFCoreVersion)
-
+
+
+ 7.0.0
+ $(EFCoreVersion)
+
diff --git a/samples/BasicSample/BasicSample.csproj b/samples/BasicSample/BasicSample.csproj
index dfef09f..937f9ed 100644
--- a/samples/BasicSample/BasicSample.csproj
+++ b/samples/BasicSample/BasicSample.csproj
@@ -10,9 +10,9 @@
-
-
-
+
+
+
diff --git a/samples/BasicSample/Program.cs b/samples/BasicSample/Program.cs
index b16b119..08c25fc 100644
--- a/samples/BasicSample/Program.cs
+++ b/samples/BasicSample/Program.cs
@@ -159,6 +159,9 @@ public static void Main(string[] args)
result = dbContext.Users.FirstOrDefault(x => x.TotalSpent > 1);
Console.WriteLine($"Our first user {result.FullName} has spent {result.TotalSpent}");
+
+ var spent = dbContext.Users.Sum(x => x.TotalSpent);
+ Console.WriteLine($"Our users combined spent: {spent}");
}
{
diff --git a/samples/ReadmeSample/ReadmeSample.csproj b/samples/ReadmeSample/ReadmeSample.csproj
index a1f59ea..2da4034 100644
--- a/samples/ReadmeSample/ReadmeSample.csproj
+++ b/samples/ReadmeSample/ReadmeSample.csproj
@@ -10,9 +10,9 @@
-
-
-
+
+
+
diff --git a/src/EntityFrameworkCore.Projectables/EntityFrameworkCore.Projectables.csproj b/src/EntityFrameworkCore.Projectables/EntityFrameworkCore.Projectables.csproj
index 079b595..9aa456d 100644
--- a/src/EntityFrameworkCore.Projectables/EntityFrameworkCore.Projectables.csproj
+++ b/src/EntityFrameworkCore.Projectables/EntityFrameworkCore.Projectables.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net7.0;net6.0
README.md
diff --git a/src/EntityFrameworkCore.Projectables/Services/ProjectableExpressionReplacer.cs b/src/EntityFrameworkCore.Projectables/Services/ProjectableExpressionReplacer.cs
index f1c4f65..57fe3aa 100644
--- a/src/EntityFrameworkCore.Projectables/Services/ProjectableExpressionReplacer.cs
+++ b/src/EntityFrameworkCore.Projectables/Services/ProjectableExpressionReplacer.cs
@@ -128,8 +128,8 @@ bool TryGetReflectedExpression(MemberInfo memberInfo, [NotNullWhen(true)] out La
var self = _AddProjectableSelect(call.Arguments.First(), _entityType);
return call.Update(null, call.Arguments.Skip(1).Prepend(self));
}
- case QueryRootExpression root:
- return _AddProjectableSelect(root, root.EntityType);
+ case QueryRootExpression root when _entityType != null:
+ return _AddProjectableSelect(root, _entityType);
default:
return ret;
}
@@ -214,7 +214,11 @@ PropertyInfo property when nodeExpression is not null
protected override Expression VisitExtension(Expression node)
{
+#if NET7_0_OR_GREATER
+ if (node is EntityQueryRootExpression root)
+#else
if (node is QueryRootExpression root)
+#endif
{
_entityType = root.EntityType;
}
diff --git a/tests/EntityFrameworkCore.Projectables.FunctionalTests/EntityFrameworkCore.Projectables.FunctionalTests.csproj b/tests/EntityFrameworkCore.Projectables.FunctionalTests/EntityFrameworkCore.Projectables.FunctionalTests.csproj
index 2e4c691..0c895e5 100644
--- a/tests/EntityFrameworkCore.Projectables.FunctionalTests/EntityFrameworkCore.Projectables.FunctionalTests.csproj
+++ b/tests/EntityFrameworkCore.Projectables.FunctionalTests/EntityFrameworkCore.Projectables.FunctionalTests.csproj
@@ -8,7 +8,7 @@
-
+