我有这个 linq 查询:
private void GetReceivedInvoiceTasks(User user, List<Task> tasks)
{
var areaIds = user.Areas.Select(x => x.AreaId).ToArray();
var taskList = from i in _db.Invoices
join a in _db.Areas on i.AreaId equals a.AreaId
where i.Status == InvoiceStatuses.Received && areaIds.Contains(a.AreaId)
select new Task {
LinkText = string.Format(Invoice {0} has been received from {1}, i.InvoiceNumber, i.Organisation.Name),
Link = Views.Edit
};
}
虽然它有问题。我正在尝试创建任务。对于每个新任务,当我将链接文本设置为像“Hello”这样的常量字符串时,这很好。但是上面我正在尝试使用发票的属性来构建属性链接文本。
我收到此错误:
base {System.SystemException} = {"LINQ to Entities 无法识别方法 'System.String Format(System.String, System.Object, System.Object)' 方法,并且此方法无法转换为存储表达式。" }
有谁知道为什么?任何人都知道这样做的另一种方法来使它工作?