我想以编程方式组合查询以创建一个查询,从而满足所有要求。我可以看到有一个联合和 ++ 运算符,但我没有看到“交集”或 **。
假设Slick FirstExample,让我们有一个代码:
val notCheap = coffees.filter(_.price>8.0)
val notExpensive = coffees.filter(_.price<9.0)
val midprice = coffees.filter(_.price>8.0).filter(_.price<9.0)
println("Midprice coffees:")
midprice foreach { case (name, supID, price, sales, total) =>
println(" " + name + "\t" + supID + "\t" + price + "\t" + sales + "\t" + total)
}
如何 create notCheap
, notExpensive
and midprice
so thatmidprice
是从创建notCheap
并notExpensive
避免代码重复的?