示例#1
0
        /// <summary>
        /// Deals with any inner facades, continuing search inside them
        /// </summary>
        /// <param name="node">Constant expression</param>
        /// <returns>The same expression, having scanned for member accesses</returns>
        protected override Expression VisitConstant(ConstantExpression node)
        {
            if (node.Type.IsGenericType && node.Type.GetGenericTypeDefinition() == typeof(FacadeTypeQueryable <>))
            {
                var provider = ((IQueryable)node.Value).Provider as FacadeTypeQueryProvider;

                if (provider != null)
                {
                    var inner = new FieldAccessExtractor();
                    foreach (var field in inner.ExtractFields(provider.Source.InnerIQueryable))
                    {
                        this.AccessedFields.Add(field);
                    }
                }
            }
            // Fix up the Expression tree to work with the underlying LINQ provider
            //if ()
            //{

            //    var provider = ((IQueryable)node.Value).Provider as FacadeTypeQueryProvider;

            //    if (provider != null)
            //    {
            //        try
            //        {
            //            return provider.Source.InnerIQueryable.Expression;
            //        }
            //        catch (Exception ex)
            //        {
            //            throw ex;
            //        }
            //    }

            //    return Source.InnerIQueryable.Expression;
            //}

            return(base.VisitConstant(node));
        }
示例#2
0
        public static HashSet <string> ExtractFields(this IQueryable iq)
        {
            var fae = new FieldAccessExtractor();

            return(fae.ExtractFields(iq));
        }