GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - EFNext/EntityFrameworkCore.Projectables: Project over properties and functions in your linq queries

BranchesTags
Open more actions menu

Latest commit

 

History

504 Commits
504 Commits

Folders and files

NameName
Last commit message
Last commit date
.devcontainer
.devcontainer
 
 
.github
.github
 
 
benchmarks/EntityFrameworkCore.Projectables.Benchmarks
benchmarks/EntityFrameworkCore.Projectables.Benchmarks
 
 
docs
docs
 
 
samples/ReadmeSample
samples/ReadmeSample
 
 
src
src
 
 
tests
tests
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
Directory.Build.props
Directory.Build.props
 
 
Directory.Packages.props
Directory.Packages.props
 
 
EntityFrameworkCore.Projectables.sln
EntityFrameworkCore.Projectables.sln
 
 
Key.snk
Key.snk
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
global.json
global.json
 
 

Repository files navigation

EntityFrameworkCore.Projectables

Flexible projection magic for EF Core

NuGet version (EntityFrameworkCore.Projectables) .NET

NuGet packages

  • EntityFrameworkCore.Projectables.Abstractions NuGet version NuGet
  • EntityFrameworkCore.Projectables NuGet version NuGet

Tip

Looking for modern C# in your queries? Check out ExpressiveSharp, the successor to Projectables (migration guide).

Getting started

  1. Install the package from NuGet
  2. Enable Projectables in your DbContext by adding: dbContextOptions.UseProjectables()
  3. Mark properties, methods, or constructors with [Projectable].
  4. Read the documentation for guides, reference, and recipes.

Example

class Order
{
    public decimal TaxRate { get; set; }
    public ICollection<OrderItem> Items { get; set; }

    [Projectable] public decimal Subtotal => Items.Sum(item => item.Product.ListPrice * item.Quantity);
    [Projectable] public decimal Tax => Subtotal * TaxRate;
    [Projectable] public decimal GrandTotal => Subtotal + Tax;
}

public static class UserExtensions
{
    [Projectable]
    public static Order GetMostRecentOrder(this User user) =>
        user.Orders.OrderByDescending(x => x.CreatedDate).FirstOrDefault();
}

var result = dbContext.Users
    .Where(u => u.UserName == "Jon")
    .Select(u => new { u.GetMostRecentOrder().GrandTotal })
    .FirstOrDefault();

The properties are inlined into SQL — no client-side evaluation, no N+1.

How it works

There are two components: a Roslyn source generator that emits companion Expression<TDelegate> trees for each [Projectable] member at compile time, and a runtime interceptor that walks your LINQ queries and substitutes those expressions before EF Core translates them to SQL.

Features (v6.x+)

Feature Docs
Properties & methods Guide →
Extension methods Guide →
Constructor projections Guide →
Method overloads Fully supported
Pattern matching (switch, is) Reference →
Block-bodied members (experimental) Advanced →
Null-conditional rewriting Reference →
Enum method expansion Reference →
UseMemberBody Reference →
Roslyn analyzers & code fixes (EFP0001–EFP0012) Reference →
Limited/Full compatibility mode Reference →

FAQ

Is this specific to a database provider?

No. The interceptor hooks into EF Core's query compilation pipeline before any provider-specific translation, so it works with SQL Server, PostgreSQL, SQLite, Cosmos DB, and any other EF Core provider.

Are there performance implications?

Two compatibility modes are available: Full (default) expands every query before handing it to EF Core; Limited expands once and caches the result. Limited mode often outperforms plain EF Core on repeated queries. See the Compatibility Mode docs.

Can I compose projectables?

Yes — a [Projectable] member can call other [Projectable] members. They are recursively inlined into the final SQL.

How does this relate to Expressionify?

Expressionify has overlapping features and a similar approach but a narrower scope. Projectables adds constructor projections, pattern matching, block-bodied members, enum expansion, and a richer diagnostics layer.

How does this relate to LinqKit/LinqExpander?

LinqKit and similar libraries predate source generators. Projectables (and Expressionify) are superior approaches for modern .NET because the source generator does the heavy lifting at compile time with no runtime reflection.

What .NET and EF Core versions are supported?

  • v1.x → EF Core 3.1 / 5
  • v2.x–v3.x → EF Core 6 / 7
  • v6.x+ → EF Core 6+ (current; targets net8.0 and net10.0)

About

Project over properties and functions in your linq queries

efnext.github.io

Topics

efcoreentity-frameworkentity-framework-coreexpression-treelinq

Resources

Readme
MIT license
Activity
Custom properties

Stars

454 stars

Watchers

8 watching

Forks

30 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.