API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Poor performance when using data class

0
Hi,

I need to load all invoice line numbers and all invoice numbers which are related to them. However, I'm getting very bad performance for the invoice numbers. Here is my code:

IProduct[] productList = sessionToEconomic.Product.GetAll();
IInvoiceLine[] invoiceLineList = sessionToEconomic.InvoiceLine.FindByProduct(productList);
IInvoiceLineData[] invoiceLineDataList = sessionToEconomic.InvoiceLineData.GetDataArray(invoiceLineList);

int invoiceLineNumber;
int invoiceNumber;

for (int i = 0; i  invoiceLineDataList.Length; i++)
{
    invoiceLineNumber = invoiceLineDataList[i].Number;
    invoiceNumber = invoiceLineDataList[i].Product.Number; //A web service call is made her each time which gives bad performance

    //invoiceLineNumber and invoiceNumber are then saved to a local SQL database

}

Thanks.
created Aug 16, 2011 by wa.ashraf
0% Accept Rate
Q 2 A 1 C 0

3 Answers

0
Hi,

This is fairly easily overcome - see this blog post for tips: http//techtalke-conomiccom/improving-api-performance-beyond-data-classes/


Best regards,
answered Aug 17, 2011 by Christian Estrup
0
Here is an example of how a dictionary with invoices as key and invoice data can be created, following the example Christian refers to:

        IInvoice[] arrInv = session.Invoice.GetAll();
        IInvoiceData arrInvData = session.InvoiceData.GetDataArray(arrInv);

        DictionaryIInvoice, IInvoiceData invData = new DictionaryIInvoice, IInvoiceData();
        for (int x = 0; x  arrInv.Length; x++)
        {
            invData[arrInv[x]] = arrInvData[x];
        }

By the way, isn't there a bug in the line that causes the round trip? You retrieve the product number. Shouldn't it be the invoice number? Like:
invoiceNumber = invoiceLineDataList[i].Invoice.Number;

Best regards
Carsten, e-conomic
answered Aug 17, 2011 by Carsten Larsen
0
Thanks a lot. This solved my performance issue

Carsten Larsen: Actually, I need to get the invoice number as well as the project number...
answered Aug 17, 2011 by wa.ashraf
Visma e-conomic A/S
...