Class EntityPropertyHelper
- Namespace
- Ecng.ComponentModel
- Assembly
- Ecng.ComponentModel.dll
Provides helper methods for retrieving entity properties from a specified type.
public static class EntityPropertyHelper
- Inheritance
-
EntityPropertyHelper
- Inherited Members
Methods
GetEntityProperties(Type, EntityProperty, Func<PropertyInfo, bool>)
Retrieves the entity properties for the specified type with a specified parent entity property.
public static IEnumerable<EntityProperty> GetEntityProperties(this Type type, EntityProperty parent, Func<PropertyInfo, bool> filter = null)
Parameters
type
TypeThe type to retrieve entity properties from.
parent
EntityPropertyThe parent EntityProperty in the hierarchy.
filter
Func<PropertyInfo, bool>An optional filter to apply to the property information.
Returns
- IEnumerable<EntityProperty>
An enumerable collection of EntityProperty.
GetEntityProperties(Type, Func<PropertyInfo, bool>)
Retrieves the entity properties for the specified type.
public static IEnumerable<EntityProperty> GetEntityProperties(this Type type, Func<PropertyInfo, bool> filter = null)
Parameters
type
TypeThe type to retrieve entity properties from.
filter
Func<PropertyInfo, bool>An optional filter to apply to the property information.
Returns
- IEnumerable<EntityProperty>
An enumerable collection of EntityProperty.
GetPropType(Type, string, Func<Type, string, Type>)
Gets the type of a nested property specified by its name.
public static Type GetPropType(this Type type, string name, Func<Type, string, Type> getVirtualProp = null)
Parameters
type
TypeThe type that contains the property.
name
stringThe dot-separated name of the property.
getVirtualProp
Func<Type, string, Type>An optional function to retrieve the type of a virtual property.
Returns
GetPropValue(object, string, Func<object, string, object>, IDictionary<string, object>)
Gets the value of a nested property from an object.
public static object GetPropValue(this object entity, string name, Func<object, string, object> getVirtualProp = null, IDictionary<string, object> vars = null)
Parameters
entity
objectThe object to retrieve the value from.
name
stringThe dot-separated name of the property.
getVirtualProp
Func<object, string, object>An optional function to retrieve the value of a virtual property.
vars
IDictionary<string, object>An optional dictionary of variables for indexing.
Returns
- object
The value of the property if found; otherwise, null.
GetVars(Type, string, Func<Type, string, Type>)
Retrieves variable names from a nested property path for the specified type.
public static IEnumerable<string> GetVars(this Type type, string name, Func<Type, string, Type> getVirtualProp = null)
Parameters
type
TypeThe type that contains the property.
name
stringThe dot-separated property path.
getVirtualProp
Func<Type, string, Type>An optional function to retrieve the type of a virtual property.
Returns
- IEnumerable<string>
An enumerable collection of variable names present in the property path.