By Marcio Valerio Silva - 10/19/2010
How Can I do to foreach all register of Business Object?
For example I have a order master-detail form and I want to Sum all Details for my order I think anything do:
int Total = 0;
for each (itemBO in ColletionBO)
Total += OrderDetailBO.Price;
enfor
How Can I do it.
at,
Marcio Valério
|
By Ivan George Borges - 10/19/2010
Hi Marcio.
Have a look at the GetEnumerable BO method at the help file under "Application Framework" / "Business Layer" / "Programatic Access" / "Data Navigation" / "Using the GetEnumerable Method".
Abraços.
|
By Marcio Valerio Silva - 10/19/2010
I did so:
private void Total()
{
int i = 0;
decimal vTotal = 0;
if (propostasProdutosBO1.Count > 0)
{
for (i = 0; i <= (propostasProdutosBO1.Count - 1); i++)
{
propostasProdutosBO1.MoveAbsolute(i);
vTotal += propostasProdutosBO1.PropostasProdutosValor;
}
lblValor.Text = vTotal.ToString();
}
else
lblValor.Text = "0,00";
}
and its work perfectly!
Thanks!
|
By Ivan George Borges - 10/19/2010
Glad you got it working.
As Superman has said many times here at the forum, there are many ways to skin a cat. 
But keep in mind that GetEnumerable is the best practice to iterate through rows within a SF Business Object.
|