private void UpdateParamentersDataGrid()
        {
            var query = SessionData.Current.SelectedQuery;
            if (query == null)
            {
                return;
            }

            var dataGrid = _view.DataGrid;
            var first = query.Parameters.FirstOrDefault();
            dataGrid.Columns.Clear();
            if (first == null)
            {
                HasParameters = false;
                dataGrid.ItemsSource = null;
                return;
            }

            _selectedParametersRecord = first;

            var columns = first
                .Properties
                .Select((x, i) => new {x.Name, Index = i})
                .ToArray();

            foreach (var column in columns)
            {
                var binding = new Binding(string.Format("Properties[{0}].Value", column.Index))
                {
                    Mode = BindingMode.OneTime
                };
                dataGrid.Columns.Add(new DataGridTextColumn {Header = column.Name, Binding = binding});
            }

            dataGrid.ItemsSource = query.Parameters;
            HasParameters = true;
            NotifyOfPropertyChange("SelectedParametersRecord");
        }
        private static IDictionary<string, object> GetRecordLookup(Record record)
        {
            if(record == null)
                return null;

            return record.Properties
                .Where(p => !p.Name.StartsWith("#"))
                .Aggregate(new Dictionary<string, object>(), (list, item) =>
                {
                    if (item.Name.StartsWith("@"))
                    {
                        list.Add(item.Name, item.Value);
                        return list;
                    }

                    if (item.Name.Equals("Value"))
                    {
                        if (list.ContainsKey("@Name"))
                        {
                            var key = list["@Name"].ToString();
                            if(!key.StartsWith("@"))
                                key = "@" + key;
                            list.Add(key, item.Value);
                            list.Remove("@Name");
                        }
                        return list;
                    }

                    list.Add("@" + item.Name, item.Value);

                    return list;
                });
        }