using System.Linq;
using Microsoft.EntityFrameworkCore;

namespace Quadarax.Foundation.Core.Data.Extensions
{
    public static class QueryableExt
    {
        public static IQueryable<TEntity> MultiInclude<TEntity>(this IQueryable<TEntity> queryable, string[] includes) where TEntity : class
        {
            if (includes.Length == 0)
                return queryable;

            foreach (var include in includes)
                queryable = queryable.Include(include);
            
            return queryable;
        }
    }
}
