Slick has no information about C , so it does not know if it can and how it should match it with the value of the database, and if it can use === on it. Thus, you get a type error. You will need to use the Scala type system to restrict the type to one for which Slick knows how to map it. You can do this by providing a so-called Context Bound, in this case :BaseColumnType .
def whereEq[C:BaseColumnType](col: RichTable.this.type => Column[C], c: C) = { q.filter { fields => col(fields) === c } }
BaseColumnType provided by Slick and, using it this way, basically tells the Scala compiler to look for an implicit value of type BaseColumnType[C] in the area where you call whereEq , because then it is usually known that C will actually be. Slick comes with BaseColumnType[Int] , BaseColumnType[String] , etc. Therefore, the Scala compiler can find it on the call site when your C really Int or String in that particular call and thus the information goes further to Slick.
Same for the LiuTiger question. abstract class Crud[..., PK:BaseColumnType] should do the trick, the dash doesn't work with context boundaries. When implementing an abstract DAO, you have to face a lot of problems and overcome your system skills like Scala and learn a little about type inference order, implicit parameters, etc.
source share