我使用Slick codegen工具并过滤掉表格并成功重命名表格和列。但是,如何跳过为不需要的列生成代码?
例如,在使用unwanted
时,如何排除items
表格中的SourceCodeGenerator
列?
答案 0 :(得分:3)
您可以按以下方式排除列:
private void BrdTracking_OnHolding(object sender, HoldingRoutedEventArgs e)
{
tbTracking.PreventKeyboardDisplayOnProgrammaticFocus = false;
tbTracking.Focus(FocusState.Programmatic);
tbTracking.PreventKeyboardDisplayOnProgrammaticFocus = true;
}
。E.g:
Table
答案 1 :(得分:0)
在Slick 3.3.0中,我必须覆盖已启用的列标志,并停止为索引和外键生成代码以使其工作:
val optDesiredColumns = Map(
"table_1" -> Set("col_1", "col_2"),
"table_2" -> Set("col_2", "col_3")
)
val codegenFuture = modelFuture.map { m =>
val model = m
new SourceCodeGenerator(model = model) {
override def Table = tableModel => {
val optDesiredColumns = tableNameToDesiredColumns.get(tableModel.name.table)
new TableDef(tableModel) {
override def Column = columnModel => {
new ColumnDef(columnModel) {
override def enabled: Boolean = {
val rv = optDesiredColumns.map(desiredColumns =>
desiredColumns.contains(columnModel.name)).
getOrElse(super.enabled)
println(s"***** ${tableModel.name.table}.${columnModel.name} enabled = $rv")
rv
}
}
}
override def Index = indexModel => {
new IndexDef(indexModel) {
override def enabled: Boolean = false
}
}
override def ForeignKey = fkModel => {
new ForeignKeyDef(fkModel) {
override def enabled: Boolean = false
}
}
}
}
}