Class ExpressionFuncTExtensions
Extension methods for System.Linq.Expressions.Expression<TDelegate> of System.Func<TResult> and System.Func<T, TResult>.
Inheritance
System.Object
ExpressionFuncTExtensions
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Sartorius.SAF.Extensions
Assembly: Sartorius.SAF.dll
Syntax
public static class ExpressionFuncTExtensions
Methods
View SourceGetPropertyInfo<T>(Expression<Func<T>>)
Gets the System.Reflection.PropertyInfo of the property that is defined within the propertyExpression
.
Declaration
public static PropertyInfo GetPropertyInfo<T>(this Expression<Func<T>> propertyExpression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T>> | propertyExpression | The property expression. |
Returns
Type | Description |
---|---|
System.Reflection.PropertyInfo | The System.Reflection.PropertyInfo. |
Type Parameters
Name | Description |
---|---|
T | The type of the property. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | propertyExpression.Body is not of type 'MemberExpression'.
or
Member defined in the |
GetPropertyName<T>(Expression<Func<T>>)
Gets the name of the property.
Declaration
public static string GetPropertyName<T>(this Expression<Func<T>> propertyExpression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T>> | propertyExpression | The property expression. |
Returns
Type | Description |
---|---|
System.String | the property name as string |
Type Parameters
Name | Description |
---|---|
T | The result of the expression (the property type). |
GetPropertyName<T, TResult>(Expression<Func<T, TResult>>)
Gets the name of a property from an expression.
Declaration
public static string GetPropertyName<T, TResult>(this Expression<Func<T, TResult>> propertyExpression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T, TResult>> | propertyExpression | The property expression. |
Returns
Type | Description |
---|---|
System.String | The property name as string |
Type Parameters
Name | Description |
---|---|
T | The type of the object root of the expression. |
TResult | The result of the expression (the property type). |
Examples
private String GetPropertyName<T, TResult>(Expression<Func<T, TResult>> expression)
{
return expression.GetPropertyName();
}