0

我有一个 LINQ 查询(与 EF 一起使用)

基本上我想根据另一列的值在选择结果中添加一列。

PaymentDate在数据库表中有列,但没有Paid列。如果PaymentDate列中为空,它也表明付款是错误的,如果它有某个日期,则表示付款是真实的。

这是我的查询,请指导我如何做到这一点。

 var selectedResults=
    from InvoiceSet in Invoices
    join BookedAreasSet in BookedAreas 
    on InvoiceSet.InvoiceID equals BookedAreasSet.InvoiceID
    join AreaSet in Areas on BookedAreasSet.AreaID equals AreaSet.AreaID
    select new     {InvoiceSet.InvoiceNumber,InvoiceSet.Amount,InvoiceSet.TotalDiscount,InvoiceSet.GST,       InvoiceSet.PaymentDate,InvoiceSet.ShoppingCentreID,BookedAreasSet.BookedAreaID,
AreaSet.Name,Here I want to add calculated value column based on InvoiceSet.PaymentDate value}
4

1 回答 1

2

我认为你应该能够做这样的事情

var selectedResults=
    from InvoiceSet in Invoices
    join BookedAreasSet in BookedAreas 
    on InvoiceSet.InvoiceID equals BookedAreasSet.InvoiceID
    join AreaSet in Areas on BookedAreasSet.AreaID equals AreaSet.AreaID
    select new { InvoiceSet.InvoiceNumber,InvoiceSet.Amount,InvoiceSet.TotalDiscount,InvoiceSet.GST,       
        InvoiceSet.PaymentDate,InvoiceSet.ShoppingCentreID,BookedAreasSet.BookedAreaID,
        AreaSet.Name,Paid = (InvoiceSet.PaymentDate == null) }
于 2012-07-10T06:44:55.543 回答