Added automatic relation mapping

This commit is contained in:
2025-01-16 15:30:52 +01:00
parent 9d9f0ef7e4
commit c3c69466d4
9 changed files with 71 additions and 41 deletions

View File

@@ -8,8 +8,10 @@ namespace HopFrame.Core.Config;
public class TableConfig {
public Type TableType { get; }
public string PropertyName { get; }
public string DisplayName { get; set; }
public DbContextConfig ContextConfig { get; }
public bool Ignored { get; set; }
internal bool Seeded { get; set; }
public List<PropertyConfig> Properties { get; } = new();
@@ -17,6 +19,7 @@ public class TableConfig {
TableType = tableType;
PropertyName = propertyName;
ContextConfig = config;
DisplayName = PropertyName;
foreach (var info in tableType.GetProperties()) {
var propConfig = new PropertyConfig(info, this);
@@ -55,6 +58,11 @@ public class TableConfig<TModel>(TableConfig config) {
configurator.Invoke(prop);
return this;
}
public TableConfig<TModel> SetDisplayName(string name) {
InnerConfig.DisplayName = name;
return this;
}
internal static PropertyInfo GetPropertyInfo<TSource, TProperty>(Expression<Func<TSource, TProperty>> propertyLambda) {
if (propertyLambda.Body is not MemberExpression member) {