scalaquery:动态批量插入
scalaquery-examples 项目中的 FirstExample 提供了使用以下语法的批量插入示例:
Coffees.insertAll(
("Colombian", 101, 7.99, 0, 0),
("French_Roast",49, 8.99, 0, 0),
("Espresso",150, 9.99, 0, 0),
("Colombian_Decaf",101, 8.99, 0, 0),
("French_Roast_Decaf", 49, 9.99, 0, 0)
)
鉴于本示例的函数定义为:如何在 InsertAll 方法中传递动态构造的元组列表:
def insertAll(values: (String, Int, Double, Int, Int)*)(implicit session: org.scalaquery.session.Session): Option[Int]
The FirstExample in scalaquery-examples project
provides an example of batch insert with the following Syntax:
Coffees.insertAll(
("Colombian", 101, 7.99, 0, 0),
("French_Roast",49, 8.99, 0, 0),
("Espresso",150, 9.99, 0, 0),
("Colombian_Decaf",101, 8.99, 0, 0),
("French_Roast_Decaf", 49, 9.99, 0, 0)
)
How is it possible to pass a dynamically constructed List of tuples in the InsertAll method given that for this example the function definition is:
def insertAll(values: (String, Int, Double, Int, Int)*)(implicit session: org.scalaquery.session.Session): Option[Int]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将列表转换为可变长度参数,如下所示:
You can transform your List to variable-length arguments like this: