Facet 1.6.0
See the version list below for details.
dotnet add package Facet --version 1.6.0
NuGet\Install-Package Facet -Version 1.6.0
<PackageReference Include="Facet" Version="1.6.0" />
<PackageVersion Include="Facet" Version="1.6.0" />
<PackageReference Include="Facet" />
paket add Facet --version 1.6.0
#r "nuget: Facet, 1.6.0"
#:package Facet@1.6.0
#addin nuget:?package=Facet&version=1.6.0
#tool nuget:?package=Facet&version=1.6.0
This is a new project, any help, feedback and contributions are highy appreciated.
Facet
"One part of a subject, situation, object that has many parts."
Facet is a C# source generator that lets you define lightweight projections (DTOs, API models, etc.) directly from your domain models — without writing boilerplate.
It generates partial classes or records with constructors, optional LINQ projections, and even supports custom mappings — all at compile time, with zero runtime cost.
- ✅ Generate classes or records from existing types
- ✅ Exclude fields/properties you don't want (basically create a Facetted view of your model))
- ✅ Include public fields (optional)
- ✅ Auto-generate constructors for fast mapping
- ✅ LINQ projection expressions
(Expression<Func<TSource,TTarget>>)
- ✅ Custom mapping via
IFacetMapConfiguration
- ✅ Use in EF Core queries by using
Facet.Extensions
Quick Start
1. Install
dotnet add package Facet
2. Define facet
using Facet;
public class Person
{
public string Name { get; set; }
public string Email { get; set; }
public int Age { get; set; }
}
// Generate a DTO that excludes Email
[Facet(typeof(Person), exclude: nameof(Person.Email))]
public partial class PersonDto;
This generates a PersonDto with only Name and Age, and a constructor that copies values.
3. Use your generated facets
var person = new Person { Name = "Alice", Email = "a@b.com", Age = 30 };
var dto = new PersonDto(person);
LINQ projection support:
var query = dbContext.People
.Select(PersonDto.Projection)
.ToList();
Advanced scenarios
Records
[Facet(typeof(Person), Kind = FacetKind.Record)]
public partial record PersonRecord;
`
Custom mapping
Eg. you need to compile extra fields
public class UserMapConfig : IFacetMapConfiguration<User, UserDto>
{
public static void Map(User source, UserDto target)
{
target.FullName = $"{source.FirstName} {source.LastName}";
}
}
[Facet(typeof(User), Configuration = typeof(UserMapConfig))]
public partial class UserDto;
This lets you add derived properties, formatting, etc.
Facet.Extensions for LINQ/EF Core async
Install Facet.Extensions for one-line mapping helpers:
dotnet add package Facet.Extensions
Then:
using Facet.Extensions;
// Single object
var dto = person.ToFacet<Person, PersonDto>();
// Lists
var dtos = people.SelectFacets<Person, PersonDto>();
// IQueryable deferred projection
var query = dbContext.People.SelectFacet<Person, PersonDto>();
And with EF Core:
var dtos = await dbContext.People.ToFacetsAsync<Person, PersonDto>();
var single = await dbContext.People.FirstFacetAsync<Person, PersonDto>();
Facet - Define less, project more.
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. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Facet:
Package | Downloads |
---|---|
Facet.Extensions
Provider-agnostic extension methods for Facet. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
2.6.1 | 38 | 9/10/2025 |
2.6.0 | 53 | 9/9/2025 |
2.5.0 | 280 | 9/4/2025 |
2.4.8 | 196 | 9/3/2025 |
2.4.7 | 242 | 9/1/2025 |
2.4.6 | 132 | 9/1/2025 |
2.4.5 | 202 | 8/30/2025 |
2.4.4 | 416 | 8/27/2025 |
2.4.3 | 189 | 8/27/2025 |
2.4.2 | 181 | 8/27/2025 |
2.4.1 | 215 | 8/26/2025 |
2.4.0 | 204 | 8/26/2025 |
2.3.0 | 1,545 | 8/20/2025 |
2.2.0 | 159 | 8/20/2025 |
2.1.0 | 267 | 8/18/2025 |
2.0.1 | 764 | 8/5/2025 |
2.0.0 | 155 | 8/4/2025 |
1.9.3 | 197 | 7/4/2025 |
1.9.1 | 156 | 7/3/2025 |
1.9.0 | 154 | 7/3/2025 |
1.8.0 | 253 | 6/4/2025 |
1.7.0 | 211 | 5/6/2025 |
1.6.0 | 180 | 4/27/2025 |
1.5.0 | 219 | 4/26/2025 |
1.4.0 | 144 | 4/25/2025 |
1.3.0 | 171 | 4/24/2025 |
1.2.0 | 176 | 4/24/2025 |
1.1.1 | 176 | 4/23/2025 |
1.1.0 | 181 | 4/23/2025 |
1.0.2 | 376 | 4/23/2025 |
1.0.1 | 191 | 4/23/2025 |
1.0.0 | 190 | 4/23/2025 |
0.1.0 | 183 | 4/22/2025 |