-
Notifications
You must be signed in to change notification settings - Fork 226
Partial properties
Simon Hughes edited this page Nov 12, 2025
·
3 revisions
With C#13, you can now have partial properties, see Microsoft documentation here
In order for you to have partial properties, in your <database.tt> file, find the Settings.UpdateColumn delegate.
There is an example of this commented out, but what you want to do is to add something like this:
Settings.UpdateColumn = delegate(Column column, Table table, List<EnumDefinition> enumDefinitions)
{
...
if (table.NameHumanCase.Equals("SomeTable", StringComparison.InvariantCultureIgnoreCase) &&
column.NameHumanCase.Equals("SomeColumn", StringComparison.InvariantCultureIgnoreCase))
column.IsPartial = true;
...For the code below, I used
if (table.NameHumanCase.Equals("AbOrderLinesAb", StringComparison.InvariantCultureIgnoreCase) &&
column.NameHumanCase.Equals("Sku", StringComparison.InvariantCultureIgnoreCase))
column.IsPartial = true;Saving the <database.tt> produces:
namespace V9EfrpgTest;
...
public partial class AbOrderLinesAb
{
public int Id { get; set; } // ID (Primary key)
public partial string Sku { get; set; } // sku (length: 15)
...
}The above Sku property is now the "declaring declaration".
You also need to create a partial class and a matching "Implementation declaration" property in another file. Here I've created a file named AbOrderLinesAb_partial.cs:
namespace V9EfrpgTest;
public partial class AbOrderLinesAb
{
private string _sku = string.Empty;
public partial string Sku
{
get => _sku;
set => _sku = value;
}
}If you have a lot of column names you would like to make partial, you can use an array like this:
var makePartial = new List<string> { "createdby", "createdon", "modifiedby", "modifiedon" };
if (makePartial.Contains(column.NameHumanCase.ToLower()))
column.IsPartial = true;