/// <summary>
        /// Get the IQueryable for the entity type represented by this table (i.e. IQueryable of Product). Retrieves it from the provided
        /// context instance, or instantiates a new context using the CreateContext().
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public virtual IQueryable GetQuery(object context)
        {
            if (context == null)
            {
                context = CreateContext();
            }

            IQueryable query = Provider.GetQuery(context);

            if (EntityType != RootEntityType)
            {
                Expression ofTypeExpression = Expression.Call(typeof(Queryable), "OfType", new[] { EntityType }, query.Expression);
                query = query.Provider.CreateQuery(ofTypeExpression);
            }

            // Return the sorted query if there is a sort column
            if (SortColumn != null)
            {
                return(Misc.BuildSortQueryable(query, this));
            }
            return(query);
        }