0
我有一个对象Rate[]
。这来自返回一个名为Rate[]
的对象的Web服务。 Rate[]
的XML如下所示:LINQ不同于某些XML节点
<b:Rate>
<b:Deductible>0</b:Deductible>
<b:FormType>AO</b:FormType>
<b:PlanCode>843</b:PlanCode>
<b:Miles>0</b:PlanMiles>
<b:PlanTerm>1</b:PlanTerm>
<b:Prefix>PR</b:Prefix>
<b:Retail>269</b:Retail>
<b:RiskPlan>RPR1</b:RiskPlan>
<b:Term>1/3</b:Term>
</b:Rate>
<b:Rate>
<b:Deductible>0</b:Deductible>
<b:FormType>AO</b:FormType>
<b:PlanCode>843</b:PlanCode>
<b:Miles>0</b:PlanMiles>
<b:PlanTerm>2</b:PlanTerm>
<b:Prefix>PR</b:Prefix>
<b:Retail>269</b:Retail>
<b:RiskPlan>RPR1</b:RiskPlan>
<b:Term>1/3</b:Term>
</b:Rate>
<b:Rate>
<b:Deductible>0</b:Deductible>
<b:FormType>AO</b:FormType>
<b:PlanCode>843</b:PlanCode>
<b:Miles>0</b:PlanMiles>
<b:PlanTerm>3</b:PlanTerm>
<b:Prefix>PR</b:Prefix>
<b:Retail>269</b:Retail>
<b:RiskPlan>RPR1</b:RiskPlan>
<b:Term>1/3</b:Term>
<b:VehicleClass>1</b:VehicleClass>
</b:Rate>
<b:Rate>
<b:Deductible>0</b:Deductible>
<b:FormType>AO</b:FormType>
<b:PlanCode>843</b:PlanCode>
<b:Miles>0</b:PlanMiles>
<b:PlanTerm>4</b:PlanTerm>
<b:Prefix>PR</b:Prefix>
<b:Retail>269</b:Retail>
<b:RiskPlan>RPR2</b:RiskPlan>
<b:Term>4/6</b:Term>
</b:Rate>
<b:Rate>
<b:Deductible>0</b:Deductible>
<b:FormType>AO</b:FormType>
<b:PlanCode>843</b:PlanCode>
<b:Miles>0</b:PlanMiles>
<b:Term>5</b:PlanTerm>
<b:Prefix>PR</b:Prefix>
<b:Retail>269</b:Retail>
<b:RiskPlan>RPR2</b:RiskPlan>
<b:Term>4/6</b:Term>
</b:Rate>
<b:Rate>
<b:Deductible>0</b:Deductible>
<b:FormType>AO</b:FormType>
<b:PlanCode>843</b:PlanCode>
<b:Miles>0</b:PlanMiles>
<b:PlanTerm>6</b:PlanTerm>
<b:Retail>269</b:Retail>
<b:RiskPlan>RPR2</b:RiskPlan>
<b:Term>4/6</b:Term>
</b:Rate>
... etc ..
<b:Rate>
<b:Deductible>0</b:Deductible>
<b:FormType>AO</b:FormType>
<b:PlanCode>843</b:PlanCode>
<b:Miles>0</b:PlanMiles>
<b:PlanTerm>84</b:PlanTerm>
<b:Retail>269</b:Retail>
<b:RiskPlan>RPR2</b:RiskPlan>
<b:Term>73/84</b:Term>
</b:Rate>
这些价格都具有相同的价格。
而不是显示1 ... 2 ... 3 ... 4 ...一直到84个术语,我想在费率中使用<Term>
对这些费率进行分组。
示例:将所有<Term>1/3</Term>
分组在一起。
注:也有不同<RiskPlan>
:RPR1,RPR2和RPR3也需要考虑。
我目前有:
var ratesGroupBy = from r in rates.GroupBy(r => new { r.Term }).Select(g => g.First())
select r;
我的问题是:
这只是返回RPR1和特别条款。它还需要考虑不同的RiskPlans及其独特术语。匿名类型实例,用string RiskPlan
和List<string> Terms
性能
RPR1 => 1/3, 4/6, 7/9, 10/12, etc...
RPR2 => 1/3, 4/6, 7/9, 10/12, etc...
RPR3 => 1/3, 4/6, 7/9, 10/12, etc...
而你的问题? –
@ L.B - 我该怎么做?我的代码没有做我需要做的事情。 – Turp