我的程序创建分区时遇到问题但没有查询每个分区。我必须使用分区的原因是因为我正在为我的服务api创建一个Odata查询字符串,如果我一次查询超过55个策略,则查询字符串变得太长而失败。我可以看到我的应用程序将策略划分为单独的分区,但就目前而言。它查询一个,然后对另一个没有任何作用。谢谢你的帮助。
**编辑一旦分区就到了
public void GetAllEligibleUnredeemedPoliciesForEachActiveAgentCodeForTheAgent()
{
AgentPoliciesForEachAgentCode = new List<DtoApp2LeadPolicy>();
foreach (var agentCode in _app2Agent.AllOfTheAgentCodesForTheAgent)
{
if (AgentPolicies != null)
AgentPolicies = new List<DtoApp2LeadPolicy>();
SetTheAgentCode(agentCode);
SetAgentPolicyNumbersByAgentCode();
SetAllPolicyNumbersByAgentsEligiblePolicies();
SetAgentPoliciesFromAtlamServices();
if (AgentPolicies != null) AgentPoliciesForEachAgentCode.AddRange(AgentPolicies);
}
}
第一个分区被跳过而没有被添加。
public void PartitionThePolicyNumbers()
{
PartitionsOfPolicyNumbers = AllPolicyNumbers.Partition<string>( NumberOfPolicyNumberPartitions);
}
public void QueryTheWebServicesForEligiblePolicyDtosUsingEachPartition()
{
foreach
(var partition in PartitionsOfPolicyNumbers)
{
SetThePolicyNumbersForThePartition(partition);
SetAgentPolicyDtosFromWebServices();
SetPoliciesForAgentView();
AddEligiblePolicyDtosFromWebServicesCallToAllEligiblePoliciesForAgent();
}
}
public void SetThePolicyNumbersForThePartition(IEnumerable<string> policyNumbers)
{
this.PolicyNumbers = policyNumbers;
}
public void AddEligiblePolicyDtosFromWebServicesCallToAllEligiblePoliciesForAgent()
{
if (AllEligiblePoliciesForAgentView == null) AllEligiblePoliciesForAgentView = new List<DtoApp2LeadPolicy>();
foreach (var policyDto in _app2Lead.AgentPolicies)
{
AllEligiblePoliciesForAgentView.Add(policyDto);
}
}
public void SetNumberOfPartitionsForPolicyNumbers()
{
NumberOfPolicyNumberPartitions = CalculateNumberOfPolicyNumberPartitions();
}
public int CalculateNumberOfPolicyNumberPartitions()
{
var numberOfPolicyNumbers = AllPolicyNumbers.Count();
if (numberOfPolicyNumbers < 55) return 1;
return (numberOfPolicyNumbers / 55) + 1;
}
答案 0 :(得分:2)
创建在Agentpoliciesforeach代码方法之外添加策略的方法
public void AddAgentPolicies()
{
if (AgentPolicies != null) AgentPoliciesForEachAgentCode.AddRange(AgentPolicies);
}