Linqraft supports several MSBuild properties to customize code generation globally.
<Project>
<PropertyGroup>
<!-- Set namespace for DTOs in global namespace. Empty means use global namespace -->
<LinqraftGlobalNamespace></LinqraftGlobalNamespace>
<!-- Generate records instead of classes -->
<LinqraftRecordGenerate>false</LinqraftRecordGenerate>
<!-- Set property accessor pattern: Default, GetAndSet, GetAndInit, GetAndInternalSet -->
<!-- Default is GetAndSet for classes, GetAndInit for records -->
<LinqraftPropertyAccessor>Default</LinqraftPropertyAccessor>
<!-- Add 'required' keyword on properties -->
<LinqraftHasRequired>true</LinqraftHasRequired>
<!-- Generate XML documentation comments -->
<!-- All (summary+reference), SummaryOnly (summary only), None (no comments) -->
<LinqraftCommentOutput>All</LinqraftCommentOutput>
<!-- Remove nullability from array-type properties -->
<LinqraftArrayNullabilityRemoval>true</LinqraftArrayNullabilityRemoval>
<!-- Use hash-named namespace for nested DTOs (e.g., LinqraftGenerated_HASH.ItemsDto) -->
<!-- When false, uses hash-suffixed class names (e.g., ItemsDto_HASH) -->
<LinqraftNestedDtoUseHashNamespace>true</LinqraftNestedDtoUseHashNamespace>
<!-- Add 'global using Linqraft;' to generated code for compatibility with v0.8.1 and earlier -->
<LinqraftGlobalUsing>true</LinqraftGlobalUsing>
</PropertyGroup>
</Project>Controls the namespace for DTOs when the source entity is in the global namespace.
<!-- Use global namespace (default) -->
<LinqraftGlobalNamespace></LinqraftGlobalNamespace>
<!-- Use specific namespace -->
<LinqraftGlobalNamespace>MyProject.Dtos</LinqraftGlobalNamespace>Generate records instead of classes:
<LinqraftRecordGenerate>true</LinqraftRecordGenerate>// Generated as record
public partial record OrderDto
{
public required int Id { get; init; }
public required string CustomerName { get; init; }
public required decimal TotalAmount { get; init; }
}Control property accessor patterns:
Default:get; set;for classes,get; init;for recordsGetAndSet:get; set;GetAndInit:get; init;GetAndInternalSet:get; internal set;
<LinqraftPropertyAccessor>GetAndInit</LinqraftPropertyAccessor>public partial class OrderDto
{
public required int Id { get; init; }
public required string CustomerName { get; init; }
}Control the required keyword on properties:
<LinqraftHasRequired>false</LinqraftHasRequired>public partial class OrderDto
{
public int Id { get; set; } // No 'required' keyword
public string CustomerName { get; set; }
}See Auto-Generated Comments for details.
See Array Nullability Removal for details.
See Nested DTO Naming for details.
Controls whether generated code includes global using Linqraft;.
<!-- Add the global using (default) -->
<LinqraftGlobalUsing>true</LinqraftGlobalUsing>
<!-- Opt out when you want to manage imports yourself -->
<LinqraftGlobalUsing>false</LinqraftGlobalUsing>This is enabled by default to preserve compatibility with Linqraft v0.8.1 and earlier.
To inspect the generated code:
- F12 (Go to Definition) on the DTO class name
- Output to files by adding these settings:
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>Generated files will be written to the Generated/ folder in your project.