所以我在关注:http ://slick.typesafe.com/doc/3.0.2/gettingstarted.html现在我想使用案例类而不是将每个模型定义为一个元组。
所以我有:
case class Character(id: Long, foreName: String, middleNames: String, lastName: String, age: Int)
//class Characters(tag: Tag) extends Table[(Int, String, String, String, Int)](tag, "characters")
class Characters(tag: Tag) extends Table[Characters](tag, "characters")
{
def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
def foreName = column[String]("forename")
def middleNames = column[String]("middlenames")
def lastName = column[String]("lastname")
def age = column[Int]("age")
// def * = (id, foreName, middleNames, lastName, age)
def * = (id, foreName, middleNames, lastName, age) <> (Character.tupled, Character.unapply _)
}
但我得到:
MappedProjection[Character, (Long, String, String, String, Int)] 类型的表达式不符合预期的类型 ProvenShape[Characters]
但这是为什么呢?它与:http: //de.slideshare.net/rebeccagrenier509/slick-learn2幻灯片 7基本相同。即使这只是 Slick 2,我如何在 Slick 3 中实现相同的效果?