C# 是否在LINQ select结果中添加计算字段?
我有一个LINQ查询(与EF一起使用) 基本上,我想根据另一列的值在selectresults中添加一列 我在DB表中有C# 是否在LINQ select结果中添加计算字段?,c#,linq,entity-framework,C#,Linq,Entity Framework,我有一个LINQ查询(与EF一起使用) 基本上,我想根据另一列的值在selectresults中添加一列 我在DB表中有PaymentDate列,但没有PaymentDate列。如果PaymentDate列中的值为空,则表示付款为假,如果其中包含某个日期,则表示付款为真 这是我的问题,请指导我怎么做 var selectedResults= from InvoiceSet in Invoices join BookedAreasSet in BookedAreas o
PaymentDate
列,但没有PaymentDate
列。如果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}
我想你应该能做这样的事情
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) }