ExpressiveSharp: Projectables, reimagined

Back in 2021 I wrote about a new library called EntityFrameworkCore.Projectables. The idea was simple: mark a property or method with [Projectable], let a source generator produce a companion expression tree for it, and EF Core can suddenly translate your computed properties to SQL. No more duplicating logic, no more over-fetching.

A lot has happened since then. Projectables grew support for block-bodied methods, switch expressions, pattern matching, constructors and more. A big shout-out goes to Fabien Ménager here, who is behind most of those features, along with a docs website, code fixes and a whole lot of performance work. But every one of those features had to fight the same wall, and at some point I had to admit that the wall was not going anywhere. So I started over. Today I want to introduce ExpressiveSharp, a reimagined Projectables that is, well, just done better. Let’s dive in and see what changed and, more importantly, why.

[Read More]

EFCore.Projectables and the curious case of an unexpected performance boost

Last time, I wrote about a new library called EntityFrameworkCore.Projectables. In short this library allows us to query over properties and methods completely written in CSharp. While I was implementing benchmarks to test the overhead of this Library, I was surprised to find out that the performance was actually improved when using Projectables over not using Projectables. Surely I must have made a mistake somewhere right? Well, lets dive in and see if we can find that out!

[Read More]

EF Projections on computed properties and methods without a hassle!

One of EF’s main selling points is that it allows you to write queries without having to deal with the underlying database technology being used. This however has its limitations as you as a developer will have likely encountered. EFCore is only able to handle expressions that are typed as such. As a result, if you try to select anything from a locally computed property or method then EFCore will have to fall back to client-side evaluation to compute the result of that expression which may be inefficient and is certainly limiting!

[Read More]