Ejemplo n.º 1
0
        public Dict FindByWord(string word, FTLangLabel lang)
        {
            var sql = string.Format(
                "SELECT {1}, {2}, {3}, {4} FROM {0} WHERE {2} = ${2} AND ({4} = ${4} OR {4} = {5}) ",
                TableName
                , Dict.FldnId, Dict.FldnWord, Dict.FldnVect, Dict.FldnLangId, (int)FTLangLabel.NotSpecified);
            var cmd = Ctx.CreateCmd(sql);

            cmd.Parameters.AddWithValue(Dict.FldnWord, word);
            cmd.Parameters.AddWithValue(Dict.FldnLangId, (int)lang);
            using (var rd = cmd.ExecuteReader())
            {
                while (rd.Read())
                {
                    return new Dict
                           {
                               Id   = rd.GetInt64(0),
                               Word = rd.GetString(1),
                               Vect = (byte[])rd[2],
                               Lang = (FTLangLabel)rd.GetInt32(3)
                           }
                }
                ;
            }
            return(null);
        }
    }
Ejemplo n.º 2
0
        public int ControlWordsIndex(bool is_enabled)
        {
            var sql = is_enabled
                ? $"CREATE INDEX IF NOT EXISTS inxWord{TableName} ON {TableName} ({Dict.FldnWord}, {Dict.FldnLangId})"
                : $"DROP INDEX inxWord{TableName}";
            var cmd = Ctx.CreateCmd(sql);

            return(cmd.ExecuteNonQuery());
        }
Ejemplo n.º 3
0
        public long?SelectInxMax()
        {
            var sql = string.Format("SELECT MAX({1}) FROM {0}",
                                    TableName, EmbedDict.FldnInx);
            var cmd = Ctx.CreateCmd(sql);
            var res = cmd.ExecuteScalar();

            return(res == null || DBNull.Value.Equals(res) ? (long?)null : Convert.ToInt64(res));
        }
Ejemplo n.º 4
0
        public IEnumerable <string> GetWordsWithEmptyVect()
        {
            var sql = string.Format(
                "SELECT {1} FROM {0} WHERE {2} IS NULL",
                TableName, Dict.FldnWord, Dict.FldnVect);
            var cmd = Ctx.CreateCmd(sql);

            using (var rd = cmd.ExecuteReader())
            {
                while (rd.Read())
                {
                    yield return(rd.GetString(0));
                }
            }
        }
Ejemplo n.º 5
0
        public IEnumerable <Dict> GetAll(FTLangLabel lang)
        {
            var sql = string.Format(
                "SELECT {1}, {2}, {3}, {4} FROM {0} WHERE {4} = ${4}",
                TableName
                , Dict.FldnId, Dict.FldnWord, Dict.FldnVect, Dict.FldnLangId);
            var cmd = Ctx.CreateCmd(sql);

            cmd.Parameters.AddWithValue(Dict.FldnLangId, (int)lang);
            using (var rd = cmd.ExecuteReader())
            {
                while (rd.Read())
                {
                    yield return new Dict
                           {
                               Id   = rd.GetInt64(0),
                               Word = rd.GetString(1),
                               Vect = (byte[])rd[2],
                               Lang = (FTLangLabel)rd.GetInt32(3)
                           }
                }
                ;
            }
        }