You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# EntitiyFrameworkCore.Projectables
2
-
Flexible projection magic for EFCore
2
+
Flexible projection magic for EF Core
3
3
4
4
[](https://www.nuget.org/packages/EntityFrameworkCore.Projectables.Abstractions/)
@@ -13,9 +13,9 @@ Flexible projection magic for EFCore
13
13
14
14
## Getting started
15
15
1. Install the package from [NuGet](https://www.nuget.org/packages/EntityFrameworkCore.Projectables/)
16
-
2. Enable Projectables in your DbContext by calling: `dbContextOptions.UseProjectables()`
17
-
3. Implement projectable properties and methods and mark them with the `[Projectable]` attribute.
18
-
4.View our [samples](https://github.com/koenbeuk/EntityFrameworkCore.Projectables/tree/master/samples) and checkout our [Blog Post](https://onthedrift.com/posts/efcore-projectables/)
16
+
2. Enable Projectables in your DbContext by adding: `dbContextOptions.UseProjectables()`
17
+
3. Implement projectable properties and methods, marking them with the `[Projectable]` attribute.
18
+
4.Explore our [samples](https://github.com/koenbeuk/EntityFrameworkCore.Projectables/tree/master/samples) and checkout our [Blog Post](https://onthedrift.com/posts/efcore-projectables/) for further guidance.
19
19
20
20
### Example
21
21
Assuming this sample:
@@ -64,38 +64,38 @@ SELECT (
64
64
WHERE (
65
65
SELECT TOP(1) [o0].[Id]
66
66
FROM [Orders] AS [o0]
67
-
WHERE([u].[Id] = [o0].[UserId])AND [o0].[FulfilledDate] IS NOT NULL
68
-
ORDER BY [o0].[CreatedDate] DESC) IS NOT NULLAND ((
67
+
WHERE [u].[Id] = [o0].[UserId] AND [o0].[FulfilledDate] IS NOT NULL
68
+
ORDER BY [o0].[CreatedDate] DESC) IS NOT NULLAND (
69
69
SELECT TOP(1) [o1].[Id]
70
70
FROM [Orders] AS [o1]
71
-
WHERE([u].[Id] = [o1].[UserId])AND [o1].[FulfilledDate] IS NOT NULL
72
-
ORDER BY [o1].[CreatedDate] DESC) = [o].[OrderId]))* (
71
+
WHERE [u].[Id] = [o1].[UserId] AND [o1].[FulfilledDate] IS NOT NULL
72
+
ORDER BY [o1].[CreatedDate] DESC) = [o].[OrderId]) * (
73
73
SELECT TOP(1) [o2].[TaxRate]
74
74
FROM [Orders] AS [o2]
75
-
WHERE([u].[Id] = [o2].[UserId])AND [o2].[FulfilledDate] IS NOT NULL
75
+
WHERE [u].[Id] = [o2].[UserId] AND [o2].[FulfilledDate] IS NOT NULL
76
76
ORDER BY [o2].[CreatedDate] DESC) AS [GrandTotal]
77
77
FROM [Users] AS [u]
78
78
WHERE [u].[UserName] = @__sampleUser_UserName_0
79
79
```
80
80
81
-
Projectable properties and methods have been inlined! the generated SQL could be improved but this is what EFCore (v5) gives us.
81
+
Projectable properties and methods have been inlined! the generated SQL could be improved but this is what EF Core (v8) gives us.
82
82
83
83
### How it works
84
-
Essentially there are 2 components: We have a source generator that is able to write companion Expression for properties and methods marked with the `Projectable` attribute. We then have a runtime component that intercepts any query and translates any call to a property or method marked with the `Projectable` attribute and translates the query to use the generated Expression instead.
84
+
Essentially, there are two components: We have a source generator that can write companion expressions for properties and methods marked with the Projectable attribute. Then, we have a runtime component that intercepts any query and translates any call to a property or method marked with the Projectable attribute, translating the query to use the generated expression instead.
85
85
86
86
### FAQ
87
87
88
88
#### Are there currently any known limitations?
89
-
There is currently no support for overloaded methods. Each method name needs to be unique within a given type.
89
+
Currently, there is no support for overloaded methods. Each method name needs to be unique within a given type.
90
90
91
91
#### Is this specific to a database provider?
92
-
No; The runtime component injects itself within the EFCore query compilation pipeline and thus has no impact on the database provider used. Of course you're still limited to whatever your database provider can do.
92
+
No, the runtime component injects itself into the EFCore query compilation pipeline, thus having no impact on the database provider used. Of course, you're still limited to whatever your database provider can do.
93
93
94
94
#### Are there performance implications that I should be aware of?
95
-
There are 2 compatibility modes: Limited and Full (Default). Most of the time, limited compatibility mode is sufficient however if you are running into issues with failed query compilation, then you may want to stick with Full compatibility mode. With Full compatibility mode, Each Query will first be expanded (Any calls to Projectable properties and methods will be replaced by their respective Expression) before being handed off to EFCore. (This is similar to how LinqKit/LinqExpander/Expressionify works). Because of this additional step, there is a small performance impact. Limited compatibility mode is smart about things and only expands the Query after it has been accepted by EF. The expanded query will then be stored in the Query Cache. With Limited compatibility you will likely see [increased](https://onthedrift.com/posts/efcore-projectables-perf/) performance over EFCore without projectables.
95
+
There are two compatibility modes: Limited and Full (Default). Most of the time, limited compatibility mode is sufficient. However, if you are running into issues with failed query compilation, then you may want to stick with Full compatibility mode. With Full compatibility mode, each query will first be expanded (any calls to Projectable properties and methods will be replaced by their respective expression) before being handed off to EFCore. (This is similar to how LinqKit/LinqExpander/Expressionify works.) Because of this additional step, there is a small performance impact. Limited compatibility mode is smart about things and only expands the query after it has been accepted by EF. The expanded query will then be stored in the Query Cache. With Limited compatibility, you will likely see increased performance over EFCore without projectables.
96
96
97
97
#### Can I call additional properties and methods from my Projectable properties and methods?
98
-
Yes you can! Any projectable property/method can call into other properties and methods as long as those properties/methods are native to EFCore or as long as they are marked with a `Projectable` attribute.
98
+
Yes, you can! Any projectable property/method can call into other properties and methods as long as those properties/methods are native to EFCore or marked with a Projectable attribute.
99
99
100
100
#### Can I use projectable extensions methods on non-entity types?
101
101
Yes you can. It's perfectly acceptable to have the following code:
@@ -160,13 +160,13 @@ ORDER BY (COALESCE("u"."FirstName", '') || ' ') || COALESCE("u"."LastName", '')
160
160
```
161
161
162
162
#### How does this relate to [Expressionify](https://github.com/ClaveConsulting/Expressionify)?
163
-
Expressionify is a project that was launched before this project. It has some overlapping features and uses similar approaches. When I first published this project, I was not aware of its existence so shame on me. Currently Expressionify targets a more focusses scope of what this project is doing and thereby it seems to be more limiting in its capabilities. Check them out though!
163
+
Expressionify is a project that was launched before this project. It has some overlapping features and uses similar approaches. When I first published this project, I was not aware of its existence, so shame on me. Currently, Expressionify targets a more focused scope of what this project is doing, and thereby it seems to be more limiting in its capabilities. Check them out though!
164
164
165
165
#### How does this relate to LinqKit/LinqExpander/...?
166
-
There are a few projects like [LinqKit](https://github.com/scottksmith95/LINQKit) that were created before we had code generators in dotnet. These are great options if you're stuck with classical EF or don't want to rely on code generation. Otherwise I would suggest that EntityFrameworkCore.Projectables and Expresssionify are superior approaches as they are able to rely on SourceGenerators to do most of the hard work.
166
+
There are a few projects like [LinqKit](https://github.com/scottksmith95/LINQKit) that were created before we had source generators in .NET. These are great options if you're stuck with classical EF or don't want to rely on code generation. Otherwise, I would suggest that EntityFrameworkCore.Projectables and Expressionify are superior approaches as they can rely on SourceGenerators to do most of the hard work.
167
167
168
168
#### Is the available for EFCore 3.1, 5 and 6?
169
-
Yes it is! there is no difference between any of these versions and you can upgrade/downgrade whenever you want.
169
+
V1 is targeting EF Core 5 and 3.1. V2 and V3 are targeting EF Core 6 and are compatible with EF Core 7. You can upgrade/downgrade between these versions based on your EF Core version requirements.
170
170
171
171
#### What is next for this project?
172
-
TBD... However one thing I'd like to improve is our Expression generation logic as its currently making a few assumptions (have yet to experience it breaking). Community contributions are very welcome!
172
+
TBD... However, one thing I'd like to improve is our expression generation logic as it's currently making a few assumptions (have yet to experience it breaking). Community contributions are very welcome!
0 commit comments