Beispiel #1
0
        public string GetUpdateQuery(TableField field, object value, string keyword)
        {
            if (field.Type.StartsWith("VARCHAR") ||
                field.Type.StartsWith("LONGTEXT"))
            {
                return($"update {TableName} set keyword = keyword & ', ' & '{keyword}' WHERE {field.Name} = '{value}';");
            }
            else if (field.Type.StartsWith("BIGINT") ||
                     field.Type.StartsWith("INT"))
            {
                return($"update {TableName} set keyword = keyword & ', ' & '{keyword}' WHERE {field.Name} = {value};");
            }

            throw new Exception(field.Type + "타입에 대한 GetUpdateQuery 함수를 완성해야 합니다.");
        }
Beispiel #2
0
        public bool KeywordExists(TableField primaryProp, object value, string keyword, OleDbConnection conn)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append($"select Keyword from {TableName} where {primaryProp.Name} = ");

            if (primaryProp.Type.StartsWith("VARCHAR") ||
                primaryProp.Type.StartsWith("LONGTEXT"))
            {
                sb.Append($"'{value}'");
            }
            else if (primaryProp.Type.StartsWith("BIGINT") ||
                     primaryProp.Type.StartsWith("INT"))
            {
                sb.Append($"{value}");
            }

            bool flag = false;

            using (OleDbCommand cm = conn.CreateCommand())
            {
                cm.CommandText = sb.ToString();

                using (OleDbDataReader reader = cm.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string findKeyword = reader["Keyword"].ToString();

                        string[] keywords = findKeyword.Split(", ");

                        if (keywords.Contains(keyword))
                        {
                            flag = true;
                            break;
                        }
                    }
                }
            }

            return(flag);
        }