Implemented deferred entry manipulation

This commit is contained in:
2025-01-28 18:10:56 +01:00
parent 5a342e2c53
commit fecbc0717b
9 changed files with 83 additions and 37 deletions

View File

@@ -12,5 +12,5 @@ public interface ITableManager {
public Task AddItem(object item);
public Task RevertChanges(object item);
public Task<string> DisplayProperty(object? item, PropertyConfig prop, object? value = null);
public Task<string> DisplayProperty(object? item, PropertyConfig prop, object? value = null, object? enumerableValue = null);
}

View File

@@ -74,7 +74,7 @@ internal sealed class TableManager<TModel>(DbContext context, TableConfig config
return false;
}
public async Task<string> DisplayProperty(object? item, PropertyConfig prop, object? value = null) {
public async Task<string> DisplayProperty(object? item, PropertyConfig prop, object? value = null, object? enumerableValue = null) {
if (item is null) return string.Empty;
if (prop.IsListingProperty)
@@ -89,12 +89,12 @@ internal sealed class TableManager<TModel>(DbContext context, TableConfig config
}
if (prop.IsEnumerable) {
if (value is not null) {
if (enumerableValue is not null) {
if (prop.EnumerableFormatter is not null) {
return await prop.EnumerableFormatter.Invoke(value, provider);
return await prop.EnumerableFormatter.Invoke(enumerableValue, provider);
}
return value.ToString() ?? string.Empty;
return enumerableValue.ToString() ?? string.Empty;
}
return (propValue as IEnumerable)!.OfType<object>().Count().ToString();