Пример #1
0
 public static IEnumerable <IQueryTable> GetTableChain(this IQueryTable table, IQueryTable context, GetPathErrorHandling errorHandling = GetPathErrorHandling.ThrowException)
 {
     return(table.GetPath(context, errorHandling));
 }
Пример #2
0
        public static IEnumerable <IQueryTable> GetPath(this IQueryTable queryTable, IQueryTable mappingContext, GetPathErrorHandling errorHandling = GetPathErrorHandling.ThrowException)
        {
            var result = GetPathRec(queryTable, mappingContext);

            // if no path was found, the context table might be after the
            // query table in the JOIN hirearchy. In this case it is ok
            // to return a path without the context table
            if (result == null)
            {
                var rs = GetPathRec(mappingContext, queryTable)
                         ?.TakeUntilIncludeLast(x => x == queryTable)
                         .ToArray();

                result = rs != null && rs[rs.Length - 1] == queryTable
                    ? rs
                    : null;
            }

            if (result == null && errorHandling == GetPathErrorHandling.ThrowException)
            {
                throw new InvalidOperationException($"You cannot use {queryTable.Alias} in the context of {mappingContext.Alias}.");
            }

            return(result);
        }