/// <summary> /// /// </summary> /// <param name="entities"></param> /// <param name="property"></param> /// <returns></returns> public static IEnumerable <TResult> Do(IEnumerable <TEntity> entities, ClassProperty property) { // Guard first Guard(property); // Variables needed var key = property.GetHashCode(); // Get from the cache if (cache.TryGetValue(key, out var func) == false) { func = GetFunc(property); } // Extract the values if (entities?.Any() == true) { foreach (var entity in entities) { yield return(func(entity)); } } }
/// <summary> /// Adds a primary property mapping into a <see cref="ClassProperty"/> object. /// </summary> /// <typeparam name="TEntity">The type of the data entity.</typeparam> /// <param name="classProperty">The instance of <see cref="ClassProperty"/> to be mapped.</param> /// <param name="force">A value that indicates whether to force the mapping. If one is already exists, then it will be overwritten.</param> internal static void Add <TEntity>(ClassProperty classProperty, bool force) where TEntity : class => Add(typeof(TEntity), classProperty, force);
/// <summary> /// Gets the values of the property of the data entities. /// </summary> /// <typeparam name="TEntity">The type of the data entities.</typeparam> /// <typeparam name="TResult">The result type of the extracted property.</typeparam> /// <param name="entities">The list of the data entities.</param> /// <param name="property">The target property.</param> /// <returns>The values of the property of the data entities.</returns> public static IEnumerable <TResult> GetEntitiesPropertyValues <TEntity, TResult>(IEnumerable <TEntity> entities, ClassProperty property) where TEntity : class { return(GetPropertyValuesCache <TEntity, TResult> .Do(entities, property)); }
/// <summary> /// Creates a new instance of <see cref="PropertyValue"/> class. /// </summary> /// <param name="name">The name of the property.</param> /// <param name="value">The value of the property.</param> /// <param name="property">The actual property object.</param> public PropertyValue(string name, object value, ClassProperty property) { Name = name; Value = value; Property = property; }
/// <summary> /// Gets the values of the property of the data entities. /// </summary> /// <typeparam name="TEntity">The type of the data entities.</typeparam> /// <typeparam name="TResult">The result type of the extracted property.</typeparam> /// <param name="entities">The list of the data entities.</param> /// <param name="property">The target property.</param> /// <returns>The values of the property of the data entities.</returns> internal static IEnumerable <TResult> GetEntitiesPropertyValues <TEntity, TResult>(IEnumerable <TEntity> entities, ClassProperty property) where TEntity : class => GetPropertyValuesCache <TEntity, TResult> .Do(entities, property);