For AI agents: the complete documentation index is available at /AchEngine/en/llms.txt, the full documentation bundle is available at /AchEngine/en/llms-full.txt, and this page is available as Markdown at /AchEngine/en/usage/table/codegen.md.

Code Generation & Runtime

Generate code

Table Loader generates type-safe C# data classes from CSV.

Id,Name,Price,IsActive
101,Iron Sword,500,TRUE
[MemoryPackable]
public partial class ItemData : ITableData
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int Price { get; set; }
    public bool IsActive { get; set; }
}

public class ItemTable : ITableDatabase<int, ItemData> { }

Click Generate Code in the Table Loader window or Project Settings › Table Loader.

Bake

Bake the generated data into .bytes when MemoryPack is installed, or .json otherwise. Files are written below binaryOutputPath.

Place files under Resources

Place baked files under a Resources/ folder so runtime code can load them with Resources.Load, for example Assets/GameData/Resources/Tables/Item.bytes.

Runtime access

var itemTable = TableManager.Get<ItemTable>();
var item = itemTable.Get(101);
Debug.Log($"{item.Name}: {item.Price}");

foreach (var row in itemTable.All)
    Debug.Log(row.Name);

Use with DI

public class GlobalInstaller : AchEngineInstaller
{
    public override void Install(IServiceBuilder builder)
        => builder.Register<ITableService, TableService>();
}

public class GameService : IGameService
{
    private readonly ITableService _tables;

    public GameService(ITableService tables) => _tables = tables;
}