Linqraft 0.7.0
dotnet add package Linqraft --version 0.7.0
NuGet\Install-Package Linqraft -Version 0.7.0
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="Linqraft" Version="0.7.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Linqraft" Version="0.7.0" />
<PackageReference Include="Linqraft"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Linqraft --version 0.7.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Linqraft, 0.7.0"
#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.
#:package Linqraft@0.7.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Linqraft&version=0.7.0
#tool nuget:?package=Linqraft&version=0.7.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Linqraft
Linqraft is a Roslyn Source Generator for easily writing IQueryable projections.
- Query-based automatic DTO generation
- You can freely define DTO structures in the query without predefining them.
- Based on anonymous types, "what you see is what you get" declarations.
- Supports nested DTOs, collections, and calculated fields.
- Null-propagation operator support (
?.) in Expression Trees- No more need to write
o.Customer != null ? o.Customer.Name : null.
- No more need to write
- Zero-dependency
- No runtime dependencies are required since it uses Source Generators and Interceptors.
For Example:
var orders = await dbContext.Orders
// Order: input entity type
// OrderDto: output DTO type (auto-generated)
.SelectExpr<Order, OrderDto>(o => new
{
// can use inferred member names
o.Id,
// null-propagation supported
// you can create flattened structures easily
CustomerName = o.Customer?.Name,
// also works for nested objects
CustomerCountry = o.Customer?.Address?.Country?.Name,
CustomerCity = o.Customer?.Address?.City?.Name,
// you can use anonymous types inside. great for grouping
CustomerInfo = new
{
Email = o.Customer?.EmailAddress,
Phone = o.Customer?.PhoneNumber,
},
// calculated fields? no problem!
LatestOrderDate = o.OrderItems.Max(oi => oi.OrderDate),
TotalAmount = o.OrderItems.Sum(oi => oi.Quantity * oi.UnitPrice),
// collections available
Items = o.OrderItems.Select(oi => new
{
// of course, features work here too
ProductName = oi.Product?.Name,
oi.Quantity
}),
})
.ToListAsync();
will be generated as:
// <auto-generated>
// This file is auto-generated by Linqraft
// </auto-generated>
#nullable enable
#pragma warning disable IDE0060
#pragma warning disable CS8601
#pragma warning disable CS8602
#pragma warning disable CS8603
#pragma warning disable CS8604
#pragma warning disable CS8618
using System;
using System.Linq;
using System.Collections.Generic;
namespace Linqraft
{
file static partial class GeneratedExpression
{
[global::System.Runtime.CompilerServices.InterceptsLocationAttribute(1, "HWIj1D9ydZTCzRj7o0y/oYkBAABUdXRvcmlhbENhc2VUZXN0LmNz")]
public static IQueryable<TResult> SelectExpr_CE7A5A7D_5A34E201<TIn, TResult>(
this IQueryable<TIn> query, Func<TIn, object> selector)
{
var matchedQuery = query as object as IQueryable<global::Tutorial.Order>;
var converted = matchedQuery.Select(o => new global::Tutorial.OrderDto
{
Id = o.Id,
CustomerName = o.Customer != null ? (string?)o.Customer.Name : null,
CustomerCountry = o.Customer != null && o.Customer.Address != null && o.Customer.Address.Country != null ? (string?)o.Customer.Address.Country.Name : null,
CustomerCity = o.Customer != null && o.Customer.Address != null && o.Customer.Address.City != null ? (string?)o.Customer.Address.City.Name : null,
CustomerInfo = new global::Tutorial.LinqraftGenerated_F1A64BF4.CustomerInfoDto
{
Email = o.Customer != null ? (string?)o.Customer.EmailAddress : null,
Phone = o.Customer != null ? (string?)o.Customer.PhoneNumber : null
},
LatestOrderDate = o.OrderItems.Max(oi => oi.OrderDate),
TotalAmount = o.OrderItems.Sum(oi => oi.Quantity * oi.UnitPrice),
Items = o.OrderItems
.Select(oi => new global::Tutorial.LinqraftGenerated_DE33EA40.ItemsDto
{
ProductName = oi.Product != null ? (string?)oi.Product.Name : null,
Quantity = oi.Quantity
})
});
return converted as object as IQueryable<TResult>;
}
}
}
namespace Tutorial
{
public partial class OrderDto
{
public required int Id { get; set; }
public required string? CustomerName { get; set; }
public required string? CustomerCountry { get; set; }
public required string? CustomerCity { get; set; }
public required global::Tutorial.LinqraftGenerated_F1A64BF4.CustomerInfoDto? CustomerInfo { get; set; }
public required global::System.DateTime LatestOrderDate { get; set; }
public required decimal TotalAmount { get; set; }
public required global::System.Collections.Generic.IEnumerable<Tutorial.LinqraftGenerated_DE33EA40.ItemsDto> Items { get; set; }
}
}
namespace Tutorial.LinqraftGenerated_DE33EA40
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
[Linqraft.LinqraftAutoGeneratedDtoAttribute]
public partial class ItemsDto
{
public required string? ProductName { get; set; }
public required int Quantity { get; set; }
}
}
namespace Tutorial.LinqraftGenerated_F1A64BF4
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
[Linqraft.LinqraftAutoGeneratedDtoAttribute]
public partial class CustomerInfoDto
{
public required string? Email { get; set; }
public required string? Phone { get; set; }
}
}
See the GitHub Repository for more details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
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 | |
|---|---|---|---|
| 0.7.0 | 195 | 12/22/2025 | |
| 0.6.2 | 445 | 12/10/2025 | |
| 0.6.1 | 180 | 12/5/2025 | |
| 0.6.0 | 662 | 12/3/2025 | |
| 0.5.3 | 668 | 12/3/2025 | |
| 0.5.2 | 666 | 12/3/2025 | |
| 0.5.1 | 666 | 12/2/2025 | |
| 0.5.0 | 663 | 12/2/2025 | |
| 0.4.3 | 669 | 12/2/2025 | |
| 0.4.2 | 560 | 12/1/2025 | |
| 0.4.1 | 560 | 12/1/2025 | |
| 0.4.0 | 181 | 11/27/2025 | |
| 0.4.0-preview.31 | 140 | 11/26/2025 | |
| 0.4.0-preview.27 | 128 | 11/25/2025 | |
| 0.4.0-preview.21 | 128 | 11/25/2025 | |
| 0.4.0-preview.19 | 134 | 11/25/2025 | |
| 0.4.0-preview.17 | 127 | 11/25/2025 | |
| 0.4.0-preview.12 | 265 | 11/21/2025 | |
| 0.4.0-preview.4 | 318 | 11/21/2025 | |
| 0.4.0-preview.0 | 331 | 11/21/2025 | |
| 0.3.8 | 371 | 11/21/2025 | |
| 0.3.7 | 386 | 11/19/2025 | |
| 0.3.6 | 393 | 11/19/2025 | |
| 0.3.5 | 395 | 11/18/2025 | |
| 0.3.4 | 301 | 11/17/2025 | |
| 0.3.3 | 304 | 11/17/2025 | |
| 0.3.2 | 298 | 11/17/2025 | |
| 0.3.1 | 444 | 11/17/2025 | |
| 0.3.0 | 222 | 11/16/2025 | |
| 0.2.3 | 284 | 11/15/2025 | |
| 0.2.2 | 282 | 11/15/2025 | |
| 0.2.1 | 285 | 11/15/2025 | |
| 0.2.0 | 301 | 11/15/2025 | |
| 0.1.6 | 218 | 11/14/2025 | |
| 0.1.5 | 239 | 11/14/2025 | |
| 0.1.4 | 249 | 11/14/2025 | |
| 0.1.3 | 248 | 11/14/2025 | |
| 0.1.2 | 260 | 11/14/2025 | |
| 0.1.1 | 261 | 11/14/2025 | |
| 0.1.0 | 271 | 11/14/2025 |