Class ExpressionFuncTExtensions
Extension methods for Expression<TDelegate> of Func<TResult> and Func<T, TResult>.
Namespace: Sartorius.SAF.Extensions
Assembly: Sartorius.SAF.dll
Syntax
public static class ExpressionFuncTExtensions
Methods
View SourceGetPropertyInfo<T>(Expression<Func<T>>)
Gets the 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 |
|---|---|---|
| Expression<Func<T>> | propertyExpression | The property expression. |
Returns
| Type | Description |
|---|---|
| PropertyInfo | The PropertyInfo. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the property. |
Exceptions
| Type | Condition |
|---|---|
| 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 |
|---|---|---|
| Expression<Func<T>> | propertyExpression | The property expression. |
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| Expression<Func<T, TResult>> | propertyExpression | The property expression. |
Returns
| Type | Description |
|---|---|
| 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