Solved

How can I get a sealed class members result from IEnumerable

  • 30 April 2022
  • 1 reply
  • 66 views

Userlevel 7
Badge +9

Hello Gang,

I have a customization project that I need to get a sealed class result ApproveInfo(the members of the class are StepID, RuleID, OwnerID, WorkgroupID and WaitTime). Below is my extension:

public virtual IEnumerable<ApproveInfo> GetApproversFromNextStep_Extension(SourceAssign Source, EPAssignmentMap AssignmentMap, int? CurrentStepSequence)
{
if (AssignmentMap == null)
{
yield break;
}

EPAssignmentProcessor<SourceAssign> assignmentProcessor = new EPAssignmentProcessor<SourceAssign>(_Graph);
foreach (ApproveInfo approveInfo in assignmentProcessor.Approve(Source, AssignmentMap, CurrentStepSequence))
{
yield return approveInfo;
}
}

Now I need the sealed calss members and values. below is the code calling the class to get these five fields but it doesn’t work for me. the result assigned to approveInfo is considered as a vaiable but I would like to access approveInfo.StepID, approveInfo.RuleID … and get their values. What I am doing wrong?

IEnumerable<ApproveInfo> approveInfo = Approval.GetApproversFromNextStep_Extension(document, assignmentMap, stepBase.Sequence);

Any help is appreciated.

icon

Best answer by aaghaei 1 May 2022, 01:12

View original

1 reply

Userlevel 7
Badge +9

I guess there should be a better way to get the expected result but here is what I did to get the five members value and works for me.

Guid? approvalStepID = approveInfo.Select(item => item.StepID).ToList().FirstOrDefault();
Guid? approvalRuleID = approveInfo.Select(item => item.RuleID).ToList().FirstOrDefault();
int? approvalOwnerID = approveInfo.Select(item => item.OwnerID).ToList().FirstOrDefault();
int? approvalWorkgroupID = approveInfo.Select(item => item.WorkgroupID).ToList().FirstOrDefault();
int? approvalWaitTime = approveInfo.Select(item => item.WaitTime).ToList().FirstOrDefault();

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved