简体   繁体   中英

Issue with Foreach to Foreach C# MVC

I have page which is show Order Details (salesLineInvoice) and under each Order details I should show Shipment details (SalesShipment) for again each Order details and there are no relation btw Order details and shipment details and then I decided have query for each of them ,which means one query for Order details Which is based on id to retrieve data for Order Details (This Part Working fine) and one Query for Shipment Details which is based on same id I mentioned before to retrieves Data for Shipment Details (I have so much problem with this part) and then in my View I did Foreach to Foreach , But I Cant figure out why the second Part Which is Shipment Details is not working . I mean i can see Ordre Details ,but nothing showed up for Shipment Details did I miss something ?! or should I use something else for this scenario like union or .. Can someone help me or point me into right direction :)

foreach (var FieldShipment in Model.ShipmentDetailLineCloses
    .Where(p=>p.DocumentNoInvoiceOrdreDeliveryClose == Field.DocumentSalesInvoice).ToList())    
{

The code inside that foreach is not outputting anything since Model.ShipmentDetailLineCloses.Where(p=>p.DocumentNoInvoiceOrdreDeliveryClose == Field.DocumentSalesInvoice).ToList() is not returning any data (given you verified that .Count was 0). Thus foreach works exactly as expected - there is no data in the List so it effectively does nothing.

As such, you need to look into how Model.ShipmentDetailLineCloses is populated - since your problem is there and not in the view itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM