示例#1
0
        private void AddNewQuery()
        {
            Z.ClearRightRegion(this.regionManager);
            IRegion rightRegion = this.regionManager.Regions[RegionNames.RightRegion];

            if (rightRegion == null)
            {
                return;
            }

            QueryExpression query = new QueryExpression(null);

            query.Expressions = new List <HermesModel>();
            queryVM           = new QueryExpressionViewModel(null, query);

            SelectStatement model = new SelectStatement(query, null);

            query.Expressions.Add(model);
            SelectStatementViewModel select = new SelectStatementViewModel(queryVM, model);

            queryVM.QueryExpressions.Add(select);

            QueryExpressionView queryView = new QueryExpressionView(queryVM);

            rightRegion.Add(queryView);
        }
示例#2
0
 private void ChangeFromOrientation()
 {
     if (queryVM != null)
     {
         if (queryVM.QueryExpressions.Count == 0)
         {
             return;
         }
         SelectStatementViewModel select = queryVM.QueryExpressions[0];
         select.IsFromVertical = !select.IsFromVertical;
     }
     else
     {
         IRegion rightRegion = this.regionManager.Regions[RegionNames.RightRegion];
         foreach (var view in rightRegion.Views)
         {
             if (view is QueryExpressionView)
             {
                 QueryExpressionViewModel vm = ((QueryExpressionView)view).DataContext as QueryExpressionViewModel;
                 if (vm != null && vm.QueryExpressions != null && vm.QueryExpressions.Count > 0)
                 {
                     SelectStatementViewModel select = vm.QueryExpressions[0] as SelectStatementViewModel;
                     if (select != null)
                     {
                         select.IsFromVertical = !select.IsFromVertical;
                     }
                 }
             }
         }
     }
 }
示例#3
0
        protected override void InitializeViewModel()
        {
            if (this.Caller == null)
            {
                throw new ArgumentOutOfRangeException("Caller");
            }

            this.DialogItems.Clear();

            QueryExpressionViewModel query = this.Caller.GetQueryExpressionViewModel(this.Caller);

            if (query == null)
            {
                throw new Exception("QueryExpressionViewModel is not found!");
            }
            this.DialogItems.Add(query);

            // TODO: при поиске SELECT нужно учитывать, что в контексте предложения JOIN список Tables
            // должен ограничиться текущим JoinTableExpression, так как по правилам SQL "нижние"
            // по спику таблицы и их поля не видны в данной области видимости
            SelectStatementViewModel select = this.Caller.GetSelectStatementViewModel(this.Caller);

            if (select == null)
            {
                throw new Exception("SelectStatementViewModel is not found!");
            }
            foreach (TableExpressionViewModel table in select.Tables)
            {
                this.DialogItems.Add(table);
            }
        }
        private void InitializeViewModel(ComparisonOperator model)
        {
            QueryExpressionViewModel query  = this.GetQueryExpressionViewModel(this);
            SelectStatementViewModel select = this.GetSelectStatementViewModel(this);

            if (select == null)
            {
                return;
            }

            if (model.LeftExpression is PropertyReference)
            {
                PropertyReference          property   = (PropertyReference)model.LeftExpression;
                TableExpressionViewModel   tableVM    = select.Tables.Where(t => t.Alias == property.Table.Alias).FirstOrDefault();
                PropertyReferenceViewModel propertyVM = new PropertyReferenceViewModel(this, tableVM, (PropertyReference)model.LeftExpression);

                this.LeftExpression     = propertyVM;
                this.LeftExpressionView = new PropertyReferenceView(propertyVM);
            }
            else if (model.LeftExpression is ParameterExpression)
            {
                if (query != null)
                {
                    ParameterExpression          expression = (ParameterExpression)model.LeftExpression;
                    ParameterExpressionViewModel vm         = query.QueryParameters.Where(p => p.Name == expression.Name).FirstOrDefault();
                    if (vm != null)
                    {
                        this.LeftExpression     = vm.GetParameterReferenceViewModel(this);
                        this.LeftExpressionView = new ParameterReferenceView((ParameterReferenceViewModel)this.LeftExpression);
                    }
                }
            }

            if (model.RightExpression is PropertyReference)
            {
                PropertyReference          property   = (PropertyReference)model.RightExpression;
                TableExpressionViewModel   tableVM    = select.Tables.Where(t => t.Alias == property.Table.Alias).FirstOrDefault();
                PropertyReferenceViewModel propertyVM = new PropertyReferenceViewModel(this, tableVM, (PropertyReference)model.RightExpression);

                this.RightExpression     = propertyVM;
                this.RightExpressionView = new PropertyReferenceView(propertyVM);
            }
            else if (model.RightExpression is ParameterExpression)
            {
                if (query != null)
                {
                    ParameterExpression          expression = (ParameterExpression)model.RightExpression;
                    ParameterExpressionViewModel vm         = query.QueryParameters.Where(p => p.Name == expression.Name).FirstOrDefault();
                    if (vm != null)
                    {
                        this.RightExpression     = vm.GetParameterReferenceViewModel(this);
                        this.RightExpressionView = new ParameterReferenceView((ParameterReferenceViewModel)this.RightExpression);
                    }
                }
            }
        }
        private void RemoveParameter()
        {
            QueryExpressionViewModel parent = this.Parent as QueryExpressionViewModel;

            if (parent == null)
            {
                return;
            }
            parent.RemoveParameterCommand.Execute(this.Name);
        }
        private void OpenTypeSelectionDialog()
        {
            QueryExpressionViewModel parent = this.Parent as QueryExpressionViewModel;

            if (parent == null)
            {
                return;
            }

            Confirmation confirmation = new Confirmation()
            {
                Title = "Select data type", Content = this
            };

            parent.TypeSelectionDialog.Raise(confirmation, response =>
            {
                if (response.Confirmed)
                {
                    OnTypeSelected(response.Content);
                }
            });
        }
        private void OpenReferenceObjectDialog()
        {
            QueryExpressionViewModel parent = this.Parent as QueryExpressionViewModel;

            if (parent == null)
            {
                return;
            }

            Entity       entity       = this.Type;
            Confirmation confirmation = new Confirmation()
            {
                Title = entity.Name, Content = entity
            };

            parent.ReferenceObjectSelectionDialog.Raise(confirmation, response =>
            {
                if (response.Confirmed)
                {
                    OnReferenceObjectSelected(response.Content);
                }
            });
        }
示例#8
0
 public QueryExpressionView(QueryExpressionViewModel viewModel) : this()
 {
     this.DataContext = viewModel;
 }