The [Facet] attribute is used to declare a new projection (facet) type based on an existing source type.
[Facet(typeof(SourceType), exclude: "Property1", "Property2")]
public partial class MyFacet { }| Parameter | Type | Description |
|---|---|---|
sourceType |
Type |
The type to project from (required). |
exclude |
string[] |
Names of properties/fields to exclude from the generated type (optional). |
IncludeFields |
bool |
Include public fields from the source type (default: false). |
GenerateConstructor |
bool |
Generate a constructor that copies values from the source (default: true). |
Configuration |
Type? |
Custom mapping config type (see Custom Mapping). |
GenerateProjection |
bool |
Generate a static LINQ projection (default: true). |
Kind |
FacetKind |
Output type: Class, Record, Struct, RecordStruct (default: Class). |
[Facet(typeof(User), exclude: nameof(User.Password), Kind = FacetKind.Record)]
public partial record UserDto;See Custom Mapping for advanced scenarios.