gpt4 book ai didi

c# - 没有从分区中获得所有结果

转载 作者:行者123 更新时间:2023-11-30 23:31:19 25 4
gpt4 key购买 nike

我的程序创建分区但不查询每个分区时遇到问题。我必须使用分区的原因是因为我正在为我的服务 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;
}

最佳答案

创建方法以在 Agentpoliciesforeach 代码方法之外添加策略

    public void AddAgentPolicies()
{
if (AgentPolicies != null) AgentPoliciesForEachAgentCode.AddRange(AgentPolicies);
}

关于c# - 没有从分区中获得所有结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34635451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com