此代码有什么问题:
_department.valuemember = "id";
var query = db.table.asqueryable();
query = query.Where(d => d.departmentID == _depatment.SelectedValue as int? );
我收到此错误: 无法创建“System.Object”类型的常量值。在此上下文中仅支持原始类型(例如Int32,String和Guid')。
我更改了代码并解决了问题:
int selectedvalue = int.parse(_department.selectedvalue.tostring());
query = query.Where(d => d.departmentID == selectedvalue );
谢谢卡梅隆:)