コード例 #1
0
ファイル: DBUtil.cs プロジェクト: chrimc62/EntityMatch
        public static long LookupFromDatabase(string server, string db, string table, string column, int nLookups, ILookupIndex t, int k)
        {
            SqlConnection connection = new SqlConnection(Util.GetConnectionString(server, db));
            connection.Open();
            string q = TrieQuery(db, table, column, nLookups);
            SqlCommand sqlcmd = new SqlCommand(q, connection);
            sqlcmd.CommandTimeout = 0;

            string[] lookupStrings = new string[nLookups];
            int idx = 0;
            using (SqlDataReader reader = sqlcmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    lookupStrings[idx++] = reader.GetString(0);
                }
            }
            connection.Close();

            Stopwatch sw = new Stopwatch();
            sw.Reset();
            sw.Start();

            foreach (string s in lookupStrings)
            {
                int nresults = t.Lookup(s, k);
            }
            sw.Stop();

            return (sw.ElapsedMilliseconds);
        }
コード例 #2
0
        public static long LookupFromDatabase(string server, string db, string table, string column, int nLookups, ILookupIndex t, int k)
        {
            SqlConnection connection = new SqlConnection(Util.GetConnectionString(server, db));

            connection.Open();
            string     q      = TrieQuery(db, table, column, nLookups);
            SqlCommand sqlcmd = new SqlCommand(q, connection);

            sqlcmd.CommandTimeout = 0;

            string[] lookupStrings = new string[nLookups];
            int      idx           = 0;

            using (SqlDataReader reader = sqlcmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    lookupStrings[idx++] = reader.GetString(0);
                }
            }
            connection.Close();

            Stopwatch sw = new Stopwatch();

            sw.Reset();
            sw.Start();

            foreach (string s in lookupStrings)
            {
                int nresults = t.Lookup(s, k);
            }
            sw.Stop();

            return(sw.ElapsedMilliseconds);
        }