This commit is contained in:
2025-10-27 17:39:18 -04:00
commit 31f723bea4
1579 changed files with 642409 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
namespace Prefab.Base;
/// <summary>
/// Represents a lookup entity that can be used to represent a PrefabEnum in a database table.
/// </summary>
/// <typeparam name="TEnum">The type that will represent the entity's backed <see cref="PrefabEnum" /> type.</typeparam>
public abstract class LookupEntity<TEnum> : ISortOrder where TEnum : PrefabEnum<TEnum>
{
/// <summary>
/// The underlying integer value of the enum.
/// </summary>
public int Id { get; set; } // This will match the PrefabEnum's underlying int value
/// <summary>
/// The name of the enum member (e.g., "Pending").
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// The short name of the enum member (e.g., "Pend").
/// </summary>
public string? ShortName { get; set; }
/// <summary>
/// An optional description of the enum member.
/// </summary>
public string? Description { get; set; }
/// <inheritdoc />
public int SortOrder { get; set; }
/// <summary>
/// Default constructor.
/// </summary>
protected LookupEntity() { }
/// <summary>
/// Constructor to create from a PrefabEnum instance.
/// </summary>
protected LookupEntity(TEnum prefabEnum)
{
Id = prefabEnum.Value;
Name = prefabEnum.Name;
ShortName = null; // Set as needed
Description = null; // Set as needed
SortOrder = prefabEnum.Value; // Or set as needed
}
/// <summary>
/// Returns all PrefabEnum instances for this type.
/// </summary>
public static IReadOnlyList<TEnum> GetAllEnumInstances() => PrefabEnum<TEnum>.List;
}