小编tai*_*ani的帖子

SqlCommand.Prepare方法要求所有参数都具有显式设置类型

我在WCF Web服务中有以下代码片段,它根据提供的字典值的格式构建一组where条件.

public static Dictionary<string, string>[] VehicleSearch(Dictionary<string, string> searchParams, int maxResults)
{
    string condition = "";
    foreach (string key in searchParams.Keys)
    {
        //Split out the conditional in case multiple options have been set (i.e. SUB;OLDS;TOY)
        string[] parameters = searchParams[key].Split(';');
        if (parameters.Length == 1)
        {
            //If a single condition (no choice list) check for wildcards and use a LIKE if necessary
            string predicate = parameters[0].Contains('%') ? " AND {0} LIKE @{0}" : " AND {0} = @{0}";
            condition += String.Format(predicate, key); …
Run Code Online (Sandbox Code Playgroud)

c# t-sql sqlcommand prepared-statement

5
推荐指数
1
解决办法
9594
查看次数

标签 统计

c# ×1

prepared-statement ×1

sqlcommand ×1

t-sql ×1