我正在将此网站php/mysql重建为 asp.net。我正在页面标题中构建主卡搜索表单。有一个文本输入、多个下拉菜单(都指向不同的列)和一些条件搜索选项。
对于 mysql 版本,我能够使用条件来构建包含查询的字符串,然后执行它。
//MySql/PHP example
$query = "SELECT * FROM cards WHERE ";
//Encounter_set
if (isset($_GET['Encounter_Set']){
$query.= "Encounter_Set=:Encounter_Set AND ";
$queryArray['Encounter_Set'] = $_GET['Encounter_Set'];
}
//radio statements
switch ($_GET['radio']) {
case "All": $query.= "(Title LIKE :terms OR Traits LIKE :terms OR Shadow_Text LIKE :terms OR Text LIKE :terms)";break;
case "Title": $query.= "(Title LIKE :terms)";break;
case "Traits": $query.= "(Traits LIKE :terms)";break;
case "Text": $query.= "(Shadow_Text LIKE :terms OR Text LIKE :terms)"; break;
default: $query.= "(Title LIKE :terms OR Traits LIKE :terms OR Shadow_Text LIKE :terms OR Text LIKE :terms)";
}
//Finally
$result = $db_con->prepare($query);
我将如何在 LINQ 中执行此操作?