internal class ClassHelper
{
internal static string GetPropertyName<TClass, T>(Expression<Func<TClass, T>> propertyExpression)
{
if (propertyExpression == null)
throw new ArgumentNullException("propertyExpression");
var memberExpression = propertyExpression.Body as MemberExpression;
if (memberExpression == null)
throw new ArgumentException("Invalid argument", "propertyExpression");
var propertyInfo = memberExpression.Member as PropertyInfo;
if (propertyInfo == (PropertyInfo)null)
throw new ArgumentException("Argument is not a property", "propertyExpression");
else
return propertyInfo.Name;
}
}
Does this work ? I wanna to get the Embedded code of the one that was generated here.
Aucun commentaire:
Enregistrer un commentaire