MySql.Data.MySqlClient.ISSchemaProvider.GetWhereClause C# (CSharp) Method

GetWhereClause() private static method

private static GetWhereClause ( string initial_where, string keys, string values ) : string
initial_where string
keys string
values string
return string
        private static string GetWhereClause(string initial_where, string[] keys, string[] values)
        {
            StringBuilder where = new StringBuilder(initial_where);
            if (values != null)
            {
                for (int i = 0; i < keys.Length; i++)
                {
                    if (i >= values.Length) break;
                    if (values[i] == null || values[i] == String.Empty) continue;
                    if (where.Length > 0)
                        where.Append(" AND ");
                    where.AppendFormat(CultureInfo.InvariantCulture, 
                        "{0} LIKE '{1}'", keys[i], values[i]);
                }
            }
            return where.ToString();
        }

Usage Example

Example #1
0
        private MySqlSchemaCollection GetParametersForRoutineFromIS(string[] restrictions)
        {
            string[] keys = new string[]
            {
                "SPECIFIC_CATALOG",
                "SPECIFIC_SCHEMA",
                "SPECIFIC_NAME",
                "ROUTINE_TYPE",
                "PARAMETER_NAME"
            };
            StringBuilder stringBuilder = new StringBuilder("SELECT * FROM INFORMATION_SCHEMA.PARAMETERS");
            string        whereClause   = ISSchemaProvider.GetWhereClause(null, keys, restrictions);

            if (!string.IsNullOrEmpty(whereClause))
            {
                stringBuilder.AppendFormat(CultureInfo.InvariantCulture, " WHERE {0}", new object[]
                {
                    whereClause
                });
            }
            MySqlSchemaCollection mySqlSchemaCollection = base.QueryCollection("parameters", stringBuilder.ToString());

            if (mySqlSchemaCollection.Rows.Count != 0 && (string)mySqlSchemaCollection.Rows[0]["routine_type"] == "FUNCTION")
            {
                mySqlSchemaCollection.Rows[0]["parameter_mode"] = "IN";
                mySqlSchemaCollection.Rows[0]["parameter_name"] = "return_value";
            }
            return(mySqlSchemaCollection);
        }
All Usage Examples Of MySql.Data.MySqlClient.ISSchemaProvider::GetWhereClause