我有三个数据表,基本上包含以下数据:
表格1:
ID FContractID | WaitingTime
1 | 1 | 85
2 | 1 | 98
3 | 1 | 122
4 | 1 | 45
5 | 1 | 234
6 | 1 | 101
等等。
表 2:
PricingCriterionItemId PricingCriterionName PricingCriterionUnit
1 | WaitingTimeMax | min
2 | WaitingTimePeriod | min
3 | WaitingTimeOverdue | €/period
4 | OverDuePriceMax | €
表3:
PricingCriterionId ContractID PricingCriterionItemId PricingCriterionValue
1 | 1 | 1 | 70
2 | 1 | 2 | 30
3 | 1 | 3 | 30,00
4 | 1 | 4 | 120,00
我想在表 1 中添加一个包含等待时间成本的列。等待时间成本将计算如下
WaitingTimeCost = min(((WaitingTime - WaitingTimeMax) / WaitingTimePeriod) * WaitingTimeOverdue, OverDuePriceMax)
是否可以使用 linq 使用其他列值在特定行上分配列值?
就像是
var result = from WaitingData in table1
join PricingCriteria in table4
on WaitingData.ContractId equals PricingCriteria.ContractId
let WaitingTimeMax = (select PricingCriterionValue from table4 where PricingCriterionName = "WaitingTimeMax")
let ...
let WaitingTimeCost = min(((WaitingTime - WaitingTimeMax) / WaitingTimePeriod) * WaitingTimeOverdue, OverDuePriceMax)
select new
{
ID,
WaitingTimeCost
}
如何使用 linq 正确地制定这个?
撒科打诨
相关分类