public override void VisitMainFromClause(MainFromClause fromClause, QueryModel queryModel)
        {
            bool processed = false;

            expression = queryModel.MainFromClause.FromExpression;
            if (expression is SubQueryExpression)
            {
                QueryModel subQueryModel = ((SubQueryExpression)expression).QueryModel;
                VisitQueryModel(subQueryModel);
                processed = true;
            }
            if (expression is ConstantExpression)
            {
                expression = Utility.DbContextHelper.GetDbSet(dbContext, (ConstantExpression)expression);
                if (BaseSourceExpressionCreated != null)
                {
                    BaseSourceExpressionCreatedEventArgs eventArgs = new BaseSourceExpressionCreatedEventArgs(expression, queryModel.MainFromClause.ItemType);
                    BaseSourceExpressionCreated(this, eventArgs);
                    expression = eventArgs.Expression;
                }
                processed = true;
            }
            if (expression is MemberExpression)
            {
                QuerySourceReferenceExpression querySourceReferenceExpression = (expression as MemberExpression)?.Expression as QuerySourceReferenceExpression;
                if (querySourceReferenceExpression != null)
                {
                    Type   paramType = querySourceReferenceExpression.ReferencedQuerySource.ItemType;
                    string paramName = querySourceReferenceExpression.ReferencedQuerySource.ItemName;
                    MainParamerExpression = Expression.Parameter(paramType, paramName);
                    expression            = UpdateExpressionVisitor.Update(expression, new[] { MainParamerExpression }, dbContext, queryContext);
                    processed             = true;
                }
            }
            if (expression is ParameterExpression)
            {
                processed = true; //TODO?
            }
            if (!processed)
            {
                throw new NotImplementedException();
            }
            entityType   = queryModel.MainFromClause.ItemType;
            selectorType = queryModel.SelectClause.Selector.Type;
        }
 private void QueryModelVisitorBaseSourceExpressionCreated(object sender, BaseSourceExpressionCreatedEventArgs e)
 {
     e.Expression = dbContextSecurity.Security.SecurityExpressionBuilder.GetDatabaseReadExpressionFromSecurity(e.Expression, e.EntityType);
 }