Query Builder Class

35 views
Skip to first unread message

Oleg

unread,
May 24, 2012, 12:12:36 PM5/24/12
to scala...@googlegroups.com
Hi

how can i create a Query Builder class!?
is meant:

val params: List[(Int, List[String), Boolean] = List(1, List("a", "b"), true)

if (params._3.size > 1) then
for{t <- Table1 if t.str inSet params._3
 ....
}
else (params._3.size == 1) then
for{t <- Table1 if t.str like params._3(0) + "%"
 ....
}
...
is ugly. How can i make following:

if (params._3.size > 1) then
condition = < t.str inSet params._3 >
 ....
}
else (params._3.size == 1) then
condition =  <t.str like params._3(0) + "%">
 ....
}
val q = for{t <- Table1 if condition
} yield t

do anyone have idea / suggestion!?

Best Regards

Oleg 
Reply all
Reply to author
Forward
0 new messages