Added relation support

This commit is contained in:
Leon Hoppe
2025-01-15 08:02:23 +01:00
parent c4c0424559
commit ad4d9c65d6
12 changed files with 93 additions and 15 deletions

View File

@@ -23,6 +23,16 @@ internal sealed class ContextExplorer(HopFrameConfig config, IServiceProvider pr
return null;
}
public TableConfig? GetTable(Type tableEntity) {
foreach (var context in config.Contexts) {
var table = context.Tables.FirstOrDefault(table => table.TableType == tableEntity);
if (table is not null)
return table;
}
return null;
}
public ITableManager? GetTableManager(string tableName) {
foreach (var context in config.Contexts) {
var table = context.Tables.FirstOrDefault(table => table.PropertyName == tableName);
@@ -32,9 +42,10 @@ internal sealed class ContextExplorer(HopFrameConfig config, IServiceProvider pr
if (dbContext is null) return null;
var type = typeof(TableManager<>).MakeGenericType(table.TableType);
return Activator.CreateInstance(type, dbContext, table) as ITableManager;
return Activator.CreateInstance(type, dbContext, table, this) as ITableManager;
}
return null;
}
}