浏览了相关的帖子,但仍然有困难。这是我的代码:
var id = Request.QueryString["id"].AsInt();
var accountNum = Request.QueryString["accountnum"];
var orderIDs = new List<OrderID>();
// Order IDs are in the form: OrderNum-OrderLine[,...]
// e.g. orderids=41417-6,36703-1
foreach (var orderID in Request.QueryString["orderids"].Split(',')) {
var components = orderID.Split('-');
orderIDs.Add(new OrderID() {
OrderNum = components[0].AsInt(),
OrderLine = components[1].AsInt()
});
}
var dbContext = new TelecomEntities();
var assignedLines = dbContext.LineAssignments
.Where(a => orderIDs
.Any(i => a.OrderNum == i.OrderNum && a.OrderLine == i.OrderLine))
.ToList();
运行此程序时,出现错误:无法创建“OrderID”类型的常量值。此上下文仅支持原始类型或枚举类型。
根据我在其他帖子中阅读的内容,我无法执行查询,因为orderIDs
不在dbContent
上下文中。
编辑: OrderID 类
public class OrderID
{
public int OrderNum { get; set; }
public int OrderLine { get; set; }
public OrderID() { }
}