Skip to content

Instantly share code, notes, and snippets.

View Qara-Penimah's full-sized avatar
🎯
Focusing

Richard Lee Qara-Penimah

🎯
Focusing
View GitHub Profile
@sandord
sandord / gist:400553
Last active September 24, 2023 08:17
Get property name from lambda expression
using System.Linq.Expressions;
/// <summary>
/// Returns the name of the specified property of the specified type.
/// </summary>
/// <typeparam name="T">The type the property is a member of.</typeparam>
/// <param name="property">The property expression.</param>
/// <returns>The property name.</returns>
public static string GetPropertyName<T>(Expression<Func<T, object>> property)
{