ReusableEfCoreIncludes 8.0.0-beta.3

This is a prerelease version of ReusableEfCoreIncludes.
dotnet add package ReusableEfCoreIncludes --version 8.0.0-beta.3
NuGet\Install-Package ReusableEfCoreIncludes -Version 8.0.0-beta.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ReusableEfCoreIncludes" Version="8.0.0-beta.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ReusableEfCoreIncludes --version 8.0.0-beta.3
#r "nuget: ReusableEfCoreIncludes, 8.0.0-beta.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ReusableEfCoreIncludes as a Cake Addin
#addin nuget:?package=ReusableEfCoreIncludes&version=8.0.0-beta.3&prerelease

// Install ReusableEfCoreIncludes as a Cake Tool
#tool nuget:?package=ReusableEfCoreIncludes&version=8.0.0-beta.3&prerelease

ReusableEfCoreIncludes

NuGet

NuGet Status NuGet Count

To install the package run the following command on the Package Manager Console:

PM> Install-Package ReusableEfCoreIncludes

This proof of concept comes with an example project and the tests associates with it to demonstrate the reusability.

Here is the example database that we will be using:

erDiagram
    Company ||--o{ Department : contains-many
    Company {
        int Id
        string Name
    }
    Department ||--o{ User : has-users
  
    Department {
        int Id
        string Name
        int LeadUserId
        int CompanyId
    }
    User |o--|| Department : has-lead-user
    User |o--|| Role : is-a
    User {
        int Id
        int RoleId
        int DepartmentId
    }
    Role {
        int Id
        int Name
    }

Here are an example of reusable includes using the wrapper created in this repository:

Can be found here

public static class ExampleIncludes
{
    public static IUIncludable<T> IncludeCompany<T>(this IUIncludable<T> source, Include<T, Company> include) where T : class =>
        source.IncludeDepartment(q => q.IncludeManyFrom(include, r => r.Departments));
  
    public static IUIncludable<T> IncludeDepartment<T, P>(this IUIncludable<T> source, Include<T, P> include)
        where T : class where P : Department =>
        source
            .IncludeUser(q => q.IncludeManyFrom(include, r => r.Users))
            .IncludeFrom(include, e => e.LeadUser);


    public static IUIncludable<T> IncludeUser<T, P>(this IUIncludable<T> source, Include<T, P> include)
        where T : class where P : User =>
        source.IncludeFrom(include, e => e.Role);
}

Here is an example of the department include being reused.

Can be found here

[Test]
public async Task TestIncludeCompany()
{
    var company = await _context!.Companies
        .BeginInclude()
        .IncludeCompany(Including.FromBase) // which also includes the department, see above!
        .AsQueryable()
        .FirstOrDefaultAsync();
    AssertCompany(company);
}

[Test]
public async Task TestIncludeDepartments()
{
    var department = await _context!.Departments
        .BeginInclude()
        .IncludeDepartment(Including.FromBase) // include the department by itself
        .AsQueryable()
        .FirstOrDefaultAsync();
    AssertDepartment(department);
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.0-beta.3 372 2/23/2024
6.0.0-beta.3 360 6/24/2023
6.0.0-beta.2 74 6/24/2023
6.0.0-beta.1 75 6/24/2023