From 56730c0d4e73048003ee27948438ac35678574fd Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 26 Mar 2026 13:42:45 +0100 Subject: [PATCH] Make GetValueByColumnName a generic extension method Refactored GetValueByColumnName to use a generic type parameter constrained to class types. This enhances type safety and enables better type inference and static analysis when accessing property values by column name. --- src/ReC.Domain/Extensions/ReflectionExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ReC.Domain/Extensions/ReflectionExtensions.cs b/src/ReC.Domain/Extensions/ReflectionExtensions.cs index 1eeb191..b3dcd57 100644 --- a/src/ReC.Domain/Extensions/ReflectionExtensions.cs +++ b/src/ReC.Domain/Extensions/ReflectionExtensions.cs @@ -9,7 +9,7 @@ public static class ReflectionExtensions /// Gets the value of a property by its column name defined in . /// Returns null if no property with the given column name exists. /// - public static object? GetValueByColumnName(this object obj, string columnName) + public static object? GetValueByColumnName(this T obj, string columnName) where T : class { var property = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance) .FirstOrDefault(p => p.GetCustomAttribute()?.Name == columnName);