EntityFrameworkCore.MemoryJoin 0.6.0

Extension for EntityFramework for joins to in-memory data

Install-Package EntityFrameworkCore.MemoryJoin -Version 0.6.0
dotnet add package EntityFrameworkCore.MemoryJoin --version 0.6.0
<PackageReference Include="EntityFrameworkCore.MemoryJoin" Version="0.6.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EntityFrameworkCore.MemoryJoin --version 0.6.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

EntityFrameworkCore.MemoryJoin

Extension for EntityFramework for joins to in-memory data. Both Entity Framework 6 and Entity Framework Core are supported!
Used SQL standard syntax.

Tested with: MSSQL and PostgreSQL. (others should also work as standard EF API and SQL standard syntax are used)

Usage

  1. Internally MemoryJoin uses intermediate class for making queries. So you can either use your own or basically use built-in one. Like this:

    protected DbSet&lt;EntityFramework.MemoryJoin.QueryModelClass&gt; QueryData { get; set; }

    Or like this for EF Core

    protected DbSet&lt;EntityFrameworkCore.MemoryJoin.QueryModelClass&gt; QueryData { get; set; }

Please note this DbSet is protected, so it can't be used by anybody, only MemoryJoin will access it.
Another note: table for QueryModelClass is NOT required. It is used for internal mapping only. So if you use migrations - basically use -IgnoreChanges flag.

  1. After DbSet is defined you can write as follows:

    using EntityFramework.MemoryJoin

    For EF Core:

    using EntityFrameworkCore.MemoryJoin

Then

// get context
var context = CreateContext();

// define in-memory list
var queryData = new [] {
    new { .StreetName = "Foo", .HouseNumber = 33 },
    new { .StreetName = "Baz", .HouseNumber = 99 },
    // can specify other objects here
};

// get queryable representation, using thing like AsQueryable() will not work
var queryable = context.FromLocalList(queryData);

// Write as complex query as you want now. Data will be sent to server for performing query. I.e.
var efQuery = from addr in context.Addresses
              join el in queryList on
                       new { addr.StreetName, addr.HouseNumber } equals
                       new { el.StreetName, el.HouseNumber }
              select new
                     {
                       addr.AddressId,
                       addr.CreatedAt,
                       addr.StreetName,
                       addr.HouseNumber,
                       el.Extra,
                       el.Integer,
                       el.Float
                     };
   
   // Query will be executed on DB server
   var = efQuery.ToList();

Some notes on how it works are here

EntityFrameworkCore.MemoryJoin

Extension for EntityFramework for joins to in-memory data. Both Entity Framework 6 and Entity Framework Core are supported!
Used SQL standard syntax.

Tested with: MSSQL and PostgreSQL. (others should also work as standard EF API and SQL standard syntax are used)

Usage

  1. Internally MemoryJoin uses intermediate class for making queries. So you can either use your own or basically use built-in one. Like this:

    protected DbSet&lt;EntityFramework.MemoryJoin.QueryModelClass&gt; QueryData { get; set; }

    Or like this for EF Core

    protected DbSet&lt;EntityFrameworkCore.MemoryJoin.QueryModelClass&gt; QueryData { get; set; }

Please note this DbSet is protected, so it can't be used by anybody, only MemoryJoin will access it.
Another note: table for QueryModelClass is NOT required. It is used for internal mapping only. So if you use migrations - basically use -IgnoreChanges flag.

  1. After DbSet is defined you can write as follows:

    using EntityFramework.MemoryJoin

    For EF Core:

    using EntityFrameworkCore.MemoryJoin

Then

// get context
var context = CreateContext();

// define in-memory list
var queryData = new [] {
    new { .StreetName = "Foo", .HouseNumber = 33 },
    new { .StreetName = "Baz", .HouseNumber = 99 },
    // can specify other objects here
};

// get queryable representation, using thing like AsQueryable() will not work
var queryable = context.FromLocalList(queryData);

// Write as complex query as you want now. Data will be sent to server for performing query. I.e.
var efQuery = from addr in context.Addresses
              join el in queryList on
                       new { addr.StreetName, addr.HouseNumber } equals
                       new { el.StreetName, el.HouseNumber }
              select new
                     {
                       addr.AddressId,
                       addr.CreatedAt,
                       addr.StreetName,
                       addr.HouseNumber,
                       el.Extra,
                       el.Integer,
                       el.Float
                     };
   
   // Query will be executed on DB server
   var = efQuery.ToList();

Some notes on how it works are here

Release Notes

Added .Net Core 3 support

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.6.0 209 9/29/2019
0.5.7 215 8/15/2019
0.5.6 2,510 3/22/2019
0.5.5 108 3/18/2019
0.5.4 1,345 12/18/2018
0.5.3 4,821 4/6/2018
0.5.2 257 3/23/2018
0.5.1 243 3/22/2018
0.5.0 283 3/20/2018