Skip to content

ExpressionExtensions

Strongly-typed property access via expression trees: resolving a PropertyInfo from a lambda and setting a property's value without reflecting by string name. (BR-061) through BR-064

Purpose

  • Strongly-typed property access via expression trees: resolving a PropertyInfo from a lambda and setting a property's value without reflecting by string name. (BR-061) through BR-064

Context

  • Namespace: SAIF.Common.Extensions
  • Assembly/package: SAIF.Framework.Common

Public members

Member Signature Purpose
GetPropertyInfo(this Expression<Func> expression) public static PropertyInfo GetPropertyInfo<TTarget,TProperty>(this Expression<Func<TTarget,TProperty>> expression) Extracts the PropertyInfo referenced by a x => x.Property lambda. (BR-061, BR-062, BR-063)
SetPropertyValue(this TTarget target, PropertyInfo property, TProperty value) public static void SetPropertyValue<TTarget,TProperty>(this TTarget target, PropertyInfo property, TProperty value) Sets a property on target given a resolved PropertyInfo. (BR-064)
SetPropertyValue(this TTarget target, Expression<Func> expression, TProperty value) public static void SetPropertyValue<TTarget,TProperty>(this TTarget target, Expression<Func<TTarget,TProperty>> expression, TProperty value) Resolves the property from a lambda expression and sets its value in one call. (BR-061, BR-062, BR-063, BR-064)

Sources

  • Common/SAIF.Common/Extensions/ExpressionExtensions.cs