BusinessObjectBase..::..GetPropertyName<(Of <(<'TObject>)>)> Method (Expression<(Of <(<'Func<(Of <(<'TObject, Object>)>)>>)>)>)
Returns the name of a property selected from TObject — useful when
you don't have an instance handy but want a refactor-safe property name string. Works for
both reference- and value-typed properties (boxing conversions are unwrapped automatically).
Namespace:
AdvantageCMS.Core.Admin.BaseClassesAssembly: AdvantageCMS.Core (in AdvantageCMS.Core.dll)
Syntax
public static string GetPropertyName<TObject>( Expression<Func<TObject, Object>> propertyRefExpr )
Type Parameters
- TObject
- The type that owns the property.
Parameters
- propertyRefExpr
- Type: Expression<(Of <(<'Func<(Of <(<'TObject, Object>)>)>>)>)>
A lambda that selects the property (for example p => p.SomeProperty).
Return Value
The property's name as a string.Examples
C#
// Reference-typed property string nameProp = BusinessObjectBase.GetPropertyName<AgentConfig>(p => p.Name); // nameProp == "Name" // Value-typed property (the cast to object is handled internally) string idProp = BusinessObjectBase.GetPropertyName<AgentConfig>(p => p.Version); // idProp == "Version" // Common use: build a column header without hard-coding the string AddColumn(BusinessObjectBase.GetPropertyName<AgentConfig>(p => p.Name), "Agent Name");

