Exemplo n.º 1
0
        public IList <LookupItem> Lookup(DataEntityType type,
                                         string filter, int top)
        {
            EnsureConnected();
            string            sql   = _queryBuilder.BuildLookup(type, filter, top);
            List <LookupItem> items = new List <LookupItem>();

            using (IDbCommand cmd = _connection.CreateCommand())
            {
                cmd.CommandText  = sql;
                using var reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    items.Add(new LookupItem
                    {
                        Id   = reader.GetInt32(0),
                        Name = reader.GetString(1)
                    });
                }
            }

            _connection.Close();
            return(items);
        }
Exemplo n.º 2
0
 private void OnGenerateLookupClick(object sender, RoutedEventArgs e)
 {
     if (_cboTables.SelectedIndex == -1)
     {
         return;
     }
     try
     {
         _txtSql.Text = _sqlBuilder.BuildLookup(
             (DataEntityType)_cboTables.SelectedIndex,
             _txtLookupFilter.Text,
             int.Parse(_txtLookupLimit.Text, CultureInfo.InvariantCulture));
         _tabs.SelectedItem = _tabSql;
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.ToString());
         MessageBox.Show(ex.Message, Title, MessageBoxButton.OK);
     }
 }