Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I use the the power of Generics to solve my issue
    text
    copied!<p>I have a wierd issue. I am loading 1k invoice objects, header first then details in my DAL. I am using VB.NET on this project. I am able to get the invoice headers just fine. When I get to loading the details for each invoice I am getting a timeout on SQL Server. I increased the timeout to 5 minutes but still the same thing. If I reduce the invoice count to 200 it works fine.</p> <p>Here is what I am doing</p> <pre> //I already loaded the invoice headers. I am now iterating each invoice to get it's detail For Each invoice As Invoice In invoices drInvoiceItems = DBSqlHelperFactory.ExecuteReader(CONNECTION_STRING, CommandType.StoredProcedure, "dbo.getinvoiceitem", _ New SqlParameter("@invoicenumber", invoice.InvoiceNumber)) While drInvoiceItems.Read() invoice.LineItems.Add(New InvoiceLine(drInvoiceItems("id"), drInvoiceItems("inv_id"), drInvoiceItems("prodid"), drInvoiceItems("name"), drInvoiceItems("barcode"), drInvoiceItems("quantity"), drInvoiceItems("costprice"))) End While Next Return invoices </pre> <p>I am aware that I am firing 1k connections to the DB due to the iterations. Can't I load all the line items with one select statement and then do something like</p> <pre><code>For Each invoice As Invoice In invoices invoice.Items.Add(invoiceItems.Find(Function(i as InvoiceItem),i.InvoiceNumber = invoice.InvoiceNumber)) Next </code></pre> <p>I get the error whenusing the lambda funcion above Error 1 Value of type 'System.Collections.Generic.List(Of BizComm.InvoiceLine)' cannot be converted to 'BizComm.InvoiceLine'. C:\Projects\BizComm\InvoiceDAL.vb 75 35 BizComm</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload