构建插入语句错误 Https 已经被声明

build insert statement error Https has already been declared

我有一个方法,它从 UI 中获取多个图像并将它们存储在缓存中,完成后它调用一个方法,然后引用缓存将图像拉出,然后将它们传递给数据库,目前这个插入语句当前正在一次执行一个操作,因此对于一个用户来说可能是 7 次访问数据库。

我想要实现的是这样的,在 SQL 中你会这样做(一次将多个项目插入到数据库中)

insert into table1 (First,Last) 
values 
     ('Fred','Smith'),
     ('John','Smith'),
     ('Michael','Smith'),
     ('Robert','Smith');

我的代码目前看起来像这样

public void SaveImages(List<Images> Images, Int64 userId)
{
  var extension = Images.Aggregate(string.Empty, (current, item) => current + string.Format("({0},{1},{2},{3},{4},{5}),", userId, item.ImageName, item.ImageUrl, 1, DateTime.Now, null));
}

完成后的扩展如下所示

(1253,xkvkvy4ldmfbhlmftqsc,https://res.cloudinary.com/dncu6pqpm/image/upload/v1423309462/rfefef.jpg,1,07/02/2015 11:45:29,),
(1253,pa0niomwvyzl47qjlxna,https://res.cloudinary.com/dncu6pqpm/image/upload/v1423309471/iuytre.jpg,1,07/02/2015 11:45:29,),
(1253,mymvektwddgco9nvbaap,https://res.cloudinary.com/dncu6pqpm/image/upload/v1423309479/sdfgh.jpg,1,07/02/2015 11:45:29,),
(1253,fxlftcx9jgrs9c7sjnv4,https://res.cloudinary.com/dncu6pqpm/image/upload/v1423309489/98iuiu.jpg,1,07/02/2015 11:45:29,),

然后我调用插入语句并传入扩展

var query = @"
           INSERT INTO [User].Images
                  (UserId, FileName, ImageUrl, Active, CreatedDate, DeletedDate)

            VALUES
                  " + extension;

sqlCon.Query(query);

但是失败了,原因如下

The label 'https' has already been declared. Label names must be unique within a query batch or stored procedure.

我用谷歌搜索了这个错误,但没有收到任何好的解决方案,所以我才来这里问。

尝试将 url(和其他字符串值)放在引号之间:

(1253,'xkvkvy4ldmfbhlmftqsc','https://res.cloudinary.com/dncu6pqpm/image/upload/v1423309462/rfefef.jpg',1,07/02/2015 11:45:29,)