Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's not 100% clear from your question but it seems you are assuming that there will only be <strong>one</strong> row corresponding to any given parameters e.g A1, B0 etc.</p> <p>In your query you are using any() to determine if the list contains any elements and then trying to return Single() which will only work if there is only one element, so why are you using an Enumerable?</p> <p>It would be better to look for the first item that corresponds to your condition and put your conditions in the order you want e.g</p> <pre><code>dtCh.AsEnumerable().OrderBy(Function(Row) Row.Field(Of Int64)("ID")).First(Function(Row) _ (Row.Field(Of String)("L_TYPE") = "A" And Row.Field(Of Int16)("Customer_Type") = 1) Or _ (Row.Field(Of String)("L_TYPE") = "B" And Row.Field(Of Int16)("Customer_Type") = 0)).Price </code></pre> <p>EDIT: Ok I didn't quite get what you are looking for. I don't know if it is possible to query multiple times in one statement but I have one solution I just tried which works. It may not be to everyones taste but I quite like it. (Wish I knew how to indent and line space in code blocks?!)</p> <pre><code>Dim Query = dtCh.AsEnumerable().OrderBy(Function(x) x.Id) Dim Conditions = { Function(Row) Row.Field(Of String)("L_TYPE") = "A" And _ Row.Field(Of Int16)("Customer_Type") = 1, Function(Row) Row.Field(Of String)("L_TYPE") = "B" And _ Row.Field(Of Int16)("Customer_Type") = 0 }.ToList() For Each Condition In Conditions Dim Price = Query.FirstOrDefault(Condition) If Price IsNot Nothing Price.Price 'Get your price here. Exit For End If Next </code></pre>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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