给出Linq查询的优化版本

时间:2015-01-06 10:25:45

标签: .net vb.net linq visual-studio-2010

我在Linq的声明中超过天真,我有一个使用谷歌准备的linq政治家。这看起来非常笨拙且难以调试。

Dim list = _
( _
    From ss In GetSelectedServicesRefactor(RecordID, DrgVersion) _
    Group Join a2c In GetA2CCPTChargesRefactor(RecordID) On ss.ServiceCode.Trim() Equals a2c.ServiceCode.Trim() Into ssa2c = Group _
    From selectedServicesA2CCharges In ssa2c.DefaultIfEmpty(Nothing)
    Group Join cdm In GetServiceChargeEstimateRefactor(RecordID, PatientType) On ss.ServiceCode.Trim() Equals cdm.ServiceCode.Trim() Into sscdm = Group _
    From selectedServicesCDMCharges In sscdm.DefaultIfEmpty(Nothing)
    Group Join ro In GetResidualOverrideConfigurationRefactor(RecordID, PatientType, facilityPlanCode, servicefieldcode, facilitypatientType) On ss.ServiceCode.Trim() Equals ro.CptCode.Trim() Into ssro = Group _
    From selectedServiceOverrideCharges In ssro.DefaultIfEmpty(Nothing)
    Group Join ps In GetPreventativeServicesListRefactor(RecordID) On ss.ServiceCode.Trim() Equals ps.CPTCode.Trim() Into ssps = Group _
    From selectedServicePreventativeCharges In ssps.DefaultIfEmpty(Nothing)
    Select New ServicesSearchInfoRefactor With _
    {
        .ServiceCode = ss.ServiceCode,
        .Description = ss.ServiceDescription,
        .Rate = GetServiceChargeAmount(selectedServicesA2CCharges, selectedServicesCDMCharges, selectedServiceOverrideCharges, selectedServicePreventativeCharges, EstFrequency),
        .Source = GetSource(selectedServicesA2CCharges, selectedServicesCDMCharges, selectedServiceOverrideCharges, selectedServicePreventativeCharges, EstFrequency),
        .AllowedAmount = GetEstimatedAllowedAmount(selectedServicesA2CCharges, selectedServicesCDMCharges, selectedServiceOverrideCharges, selectedServicePreventativeCharges, EstFrequency),
        .IsPreventativeService = IIf(selectedServicePreventativeCharges Is Nothing, False, True),
        .HasOverrideAllowedAmount = GetHasOverrideAllowedAmount(selectedServiceOverrideCharges),
        .OverrideAllowedAmount = GetOverrideAllowedAmount(selectedServiceOverrideCharges),
        .HasOverrideChargeAmount = GetHasOverrideChargeAmount(selectedServiceOverrideCharges) _
    } _
).ToList()

我只想要一个更干净,可调试的部分。

0 个答案:

没有答案