Пример #1
0
        //m.Expression is null in the case of a static member
        protected override Expression VisitMemberAccess(MemberExpression m)
        {
            Expression translatedM = null;

            //Handles Member referencing constant
            if (IsReferencingConstantValue(m))
            {
                translatedM = (typeof(IEntity).IsAssignableFrom(m.Type)) ? GetTableEntityExpression(m) : (Expression)m;
                AnalysisContext.QueryableType = GetQueryableType(m.Type, translatedM.Type);
            }
            //Handles static members
            else if (m.Expression == null)
            {
                translatedM = base.VisitMemberAccess(m) as MemberExpression;
                AnalysisContext.QueryableType = SimpleType.GetMember(AnalysisContext.QueryableType, m, translatedM as MemberExpression,
                                                                     AnalysisContext.TypeTranslationUtil);
            }
            else
            {
                var exp = base.Visit(m.Expression);
                translatedM = TypeTranslationUtil.GetTranslatedMemberExpression(m.Expression.Type, AnalysisContext.QueryableType.GetMemberName(m.Member), exp);
                AnalysisContext.QueryableType = SimpleType.GetMember(AnalysisContext.QueryableType, m, translatedM as MemberExpression,
                                                                     AnalysisContext.TypeTranslationUtil);
            }

            return(translatedM);
        }