dapper 写查询sql 时,多条件参数操作方法

var args = new DynamicParameters(new {});





   if (obj.orderId != null)

   {

        sb.Append(" AND OrderId = @OrderId");

        args.Add("OrderId", obj.orderId);

    }



    if (obj.clientName != null)

   {

        sb.Append("  AND b.Name = @ClientName");

        args.Add("ClientName", obj.clientName); 

    }



conn.Query<TModel>(sql, args );   

参考:

http://stackoverflow.com/questions/22978754/send-sqlparameter-to-dapper

你可能感兴趣的:(sql)