Impatient.EntityFrameworkCore.SqlServer 2.1.2

An alternative query compiler for Microsoft.EntityFrameworkCore.SqlServer that supports complex queries and operators and FOR JSON.

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

Supports EF Core 2.1.0 with SQL Server 2016+.

After installing, configure your DbContext like this:

services.AddDbContext<NorthwindDbContext>(options =>
{
    options
        .UseSqlServer(connectionString)
        .UseImpatient();
});

Use Impatient with EF Core for SQL Server to get the most out of LINQ queries.

Impatient speaks JSON, so you can fetch dense result sets in one trip:

from e in employees
select new
{
    e.FirstName,
    e.LastName,
    RecentOrders = 
        (from o in e.Orders
         orderby o.OrderDate descending
         select o).Take(5).ToList(),
    TopCustomers = 
        (from o in e.Orders
         from d in o.OrderDetails
         group d by o.Customer into g
         let total = g.Sum(d => d.UnitPrice * d.Quantity * (decimal)(1 - d.Discount))
         orderby total descending
         select new
         {
             g.Key.ContactName,
             g.Key.CompanyName,
             total
         }).Take(5).ToList()
}
SELECT [e].[FirstName] AS [FirstName], [e].[LastName] AS [LastName], (
    SELECT TOP (5) [o].[OrderID] AS [OrderID], [o].[CustomerID] AS [CustomerID], [o].[EmployeeID] AS [EmployeeID], [o].[OrderDate] AS [OrderDate]
    FROM [Orders] AS [o]
    WHERE [o].[EmployeeID] = [e].[EmployeeID]
    ORDER BY [o].[OrderDate] DESC
    FOR JSON PATH
) AS [RecentOrders], (
    SELECT TOP (5) [c].[ContactName] AS [ContactName], [c].[CompanyName] AS [CompanyName], SUM(([o_0].[UnitPrice] * CAST([o_0].[Quantity] AS decimal(18, 2))) * CAST(1 - [o_0].[Discount] AS decimal(18, 2))) AS [total]
    FROM [Orders] AS [o_1]
    INNER JOIN [Order Details] AS [o_0] ON [o_1].[OrderID] = [o_0].[OrderID]
    LEFT JOIN (
        SELECT [c_0].[CustomerID] AS [CustomerID], [c_0].[Address] AS [Address], [c_0].[City] AS [City], [c_0].[CompanyName] AS [CompanyName], [c_0].[ContactName] AS [ContactName], [c_0].[ContactTitle] AS [ContactTitle], [c_0].[Country] AS [Country], [c_0].[Fax] AS [Fax], [c_0].[Phone] AS [Phone], [c_0].[PostalCode] AS [PostalCode], [c_0].[Region] AS [Region]
        FROM [Customers] AS [c_0]
    ) AS [c] ON [o_1].[CustomerID] = [c].[CustomerID]
    WHERE [o_1].[EmployeeID] = [e].[EmployeeID]
    GROUP BY [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region]
    ORDER BY SUM(([o_0].[UnitPrice] * CAST([o_0].[Quantity] AS decimal(18, 2))) * CAST(1 - [o_0].[Discount] AS decimal(18, 2))) DESC
    FOR JSON PATH
) AS [TopCustomers]
FROM [Employees] AS [e]

For more information, see the project site.

Supports EF Core 2.1.0 with SQL Server 2016+.

After installing, configure your DbContext like this:

services.AddDbContext<NorthwindDbContext>(options =>
{
    options
        .UseSqlServer(connectionString)
        .UseImpatient();
});

Use Impatient with EF Core for SQL Server to get the most out of LINQ queries.

Impatient speaks JSON, so you can fetch dense result sets in one trip:

from e in employees
select new
{
    e.FirstName,
    e.LastName,
    RecentOrders = 
        (from o in e.Orders
         orderby o.OrderDate descending
         select o).Take(5).ToList(),
    TopCustomers = 
        (from o in e.Orders
         from d in o.OrderDetails
         group d by o.Customer into g
         let total = g.Sum(d => d.UnitPrice * d.Quantity * (decimal)(1 - d.Discount))
         orderby total descending
         select new
         {
             g.Key.ContactName,
             g.Key.CompanyName,
             total
         }).Take(5).ToList()
}
SELECT [e].[FirstName] AS [FirstName], [e].[LastName] AS [LastName], (
    SELECT TOP (5) [o].[OrderID] AS [OrderID], [o].[CustomerID] AS [CustomerID], [o].[EmployeeID] AS [EmployeeID], [o].[OrderDate] AS [OrderDate]
    FROM [Orders] AS [o]
    WHERE [o].[EmployeeID] = [e].[EmployeeID]
    ORDER BY [o].[OrderDate] DESC
    FOR JSON PATH
) AS [RecentOrders], (
    SELECT TOP (5) [c].[ContactName] AS [ContactName], [c].[CompanyName] AS [CompanyName], SUM(([o_0].[UnitPrice] * CAST([o_0].[Quantity] AS decimal(18, 2))) * CAST(1 - [o_0].[Discount] AS decimal(18, 2))) AS [total]
    FROM [Orders] AS [o_1]
    INNER JOIN [Order Details] AS [o_0] ON [o_1].[OrderID] = [o_0].[OrderID]
    LEFT JOIN (
        SELECT [c_0].[CustomerID] AS [CustomerID], [c_0].[Address] AS [Address], [c_0].[City] AS [City], [c_0].[CompanyName] AS [CompanyName], [c_0].[ContactName] AS [ContactName], [c_0].[ContactTitle] AS [ContactTitle], [c_0].[Country] AS [Country], [c_0].[Fax] AS [Fax], [c_0].[Phone] AS [Phone], [c_0].[PostalCode] AS [PostalCode], [c_0].[Region] AS [Region]
        FROM [Customers] AS [c_0]
    ) AS [c] ON [o_1].[CustomerID] = [c].[CustomerID]
    WHERE [o_1].[EmployeeID] = [e].[EmployeeID]
    GROUP BY [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region]
    ORDER BY SUM(([o_0].[UnitPrice] * CAST([o_0].[Quantity] AS decimal(18, 2))) * CAST(1 - [o_0].[Discount] AS decimal(18, 2))) DESC
    FOR JSON PATH
) AS [TopCustomers]
FROM [Employees] AS [e]

For more information, see the project site.

Version History

Version Downloads Last updated
2.1.2 3,974 8/16/2018
2.1.1 658 6/14/2018
2.1.0 344 5/30/2018
2.1.0-rc1-final 144 5/18/2018
2.0.0 510 4/23/2018