Пример #1
0
        public virtual IList <object> GetList(SqlListGenerator generator)
        {
            HashSet <object> set = new HashSet <object>();

            using (var conn = CreateConnection())
            {
                conn.Open();
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandTimeout = CommandTimeout;
                    generator.UpdateCommand(cmd);
                    using (var reader = cmd.ExecuteReader())
                    {
                        int idx = -1;
                        try { idx = reader.GetOrdinal("ID"); }
                        catch { }

                        while (reader.Read())
                        {
                            // assumes either 1 or 2 columns. If 2, one will be ID column
                            var item = reader.GetValue(idx != -1 ? 1 - idx : 0);
                            if (!set.Contains(item))
                            {
                                set.Add(item);
                            }
                        }
                    }
                }
            }
            return(new List <object>(set));
        }
Пример #2
0
 private int Execute(SqlListGenerator generator)
 {
     using (var cmd = _conn.CreateCommand())
     {
         generator.UpdateCommand(cmd);
         return(cmd.ExecuteNonQuery());
     }
 }
Пример #3
0
        private int Execute(SqlListGenerator generator)
        {
            using (var cmd = _conn.CreateCommand())
            {
                generator.UpdateCommand(cmd);

                System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter((System.Data.SqlClient.SqlCommand)cmd); //we are now tieing ourselves to SQL
                System.Data.DataTable tbl = new System.Data.DataTable();
                adapter.Fill(tbl);

                return(tbl.Rows.Count);
            }
        }