/// <summary> /// The get entities. /// </summary> /// <param name="collection"> /// The collection. /// </param> /// <typeparam name="T"> /// The type of <see cref="IEntity"/> /// </typeparam> /// <returns> /// The <see cref="IEnumerable{T}"/>. /// </returns> public static IEnumerable <T> GetEntities <T>(this IEntityCollection collection) where T : class, IEntity { var resolved = collection.ResolveProvider(); return(resolved == null?Enumerable.Empty <T>() : resolved.GetEntities <T>()); }
/// <summary> /// Gets a generic page of Entities. /// </summary> /// <param name="collection"> /// The collection. /// </param> /// <param name="page"> /// The page. /// </param> /// <param name="itemsPerPage"> /// The items per page. /// </param> /// <param name="sortBy"> /// The sort by. /// </param> /// <param name="sortDirection"> /// The sort direction. /// </param> /// <returns> /// The <see cref="Page"/>. /// </returns> public static Page <object> GetPagedEntities( this IEntityCollection collection, long page, long itemsPerPage, string sortBy = "", SortDirection sortDirection = SortDirection.Ascending) { var resolved = collection.ResolveProvider(); return(resolved == null ? new Page <object>() : resolved.GetPagedEntities(page, itemsPerPage, sortBy, sortDirection)); }
/// <summary> /// The resolve provider. /// </summary> /// <param name="collection"> /// The collection. /// </param> /// <typeparam name="T"> /// The type of provider /// </typeparam> /// <returns> /// The <see cref="EntityCollectionProviderBase"/>. /// </returns> internal static T ResolveProvider <T>(this IEntityCollection collection) where T : class { var provider = collection.ResolveProvider(); if (provider == null) { return(null); } if (provider is T) { return(provider as T); } LogHelper.Debug(typeof(EntityCollectionExtensions), "Provider was resolved but was not of expected type."); return(null); }
/// <summary> /// The get entities. /// </summary> /// <param name="collection"> /// The collection. /// </param> /// <returns> /// The <see cref="IEnumerable{Object}"/>. /// </returns> public static IEnumerable <object> GetEntities(this IEntityCollection collection) { var resolved = collection.ResolveProvider(); return(resolved == null?Enumerable.Empty <object>() : resolved.GetEntities()); }
/// <summary> /// The resolve validated provider. /// </summary> /// <param name="collection"> /// The collection. /// </param> /// <param name="entity"> /// The entity. /// </param> /// <typeparam name="T"> /// The type of the <see cref="IEntity"/> /// </typeparam> /// <returns> /// The <see cref="EntityCollectionProviderBase"/>. /// </returns> internal static EntityCollectionProviderBase <T> ResolveValidatedProvider <T>(this IEntityCollection collection, T entity) where T : class, IEntity { var resolved = collection.ResolveProvider(); return(resolved is EntityCollectionProviderBase <T>?resolved as EntityCollectionProviderBase <T> : null); }