NameOf

Fills a gap in nameof by allowing you to use deep name references instead of local name references.

Syntax

public static class NameOf

Inheritance

Methods

Full<TSource>

public static string Full<TSource>(Expression<Func<TSource, object>> expression, string separator = ".")
Gets the full property path name from the specified expression, optionally using a custom separator.

Parameters

  • expression Expression<Func<TSource, object>>: An expression pointing to the property whose full name should be returned.
  • separator string: The character(s) used to separate property names in the result. Defaults to ”.”.

Returns

string The full property path as a string with the specified separator.

Full<TSource>

public static string Full<TSource>(string sourceFieldName, Expression<Func<TSource, object>> expression, string separator = ".")
Allows you to create a source name expression when you need to have a prefixing variable in the result.

Parameters

Returns

string

Remarks

Solution modified from https://stackoverflow.com/a/58190566/403765.