Note that there are some explanatory texts on larger screens.

plurals
  1. POConcatenate values in List
    primarykey
    data
    text
    <p>I have DTO consists of List of DeliveryNote, List of Customer. Each Delivery Note contains List of Quotations so that each delivery note have multiple quotations. But only same customer. Customer reference is in Quotations only. </p> <p>I need to select the query like delivery note date, number and Reference in Quotation List separated by comma (if multiple). </p> <p>I write LINQ like below</p> <pre><code> var source = from A in _deliveryNote.DeliveryNoteList select new { A.ID, A.Date, A.Number, Reference = String.Join(", ", from item in A.Quotations select item.Reference), CustomerName = (A.Quotations != null ? _deliveryNote.CustomerList.Find(x =&gt; x.ID == A.Quotations.First().CustomerID).Name : string.Empty) }; </code></pre> <p>This is working nice. But i need some tips like my unhandled case like if no quotations are available how it is handled and also when single wuotation is applicable how to avoid comma.</p> <p>Also i got some other type of query like below. </p> <pre><code>var source = from A in _deliveryNote.DeliveryNoteList from B in A.Quotations select new { A.ID, A.Date, A.Number, //Reference = String.Join(", ", from item in A.Quotations select item.Reference), //CustomerName = (A.Quotations != null ? _deliveryNote.CustomerList.Find(x =&gt; x.ID == A.Quotations.First().CustomerID).Name : string.Empty) //_deliveryNote.CustomerList.Find(x =&gt; x.ID == C.CustomerID).Name : String.Empty) }; </code></pre> <p>But here i don't know how i concatenate references and retrieve customer name</p> <p>Please guide me which is better way and also what is the difference between both approach</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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