Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Till is on the right track there, but did not give the correct syntax. The broker is used to load collections from the current Data Accessor, not for creating new ones. So the code would then be:</p> <pre><code>public IEnumerable&lt;Customer&gt; FindCustomers(string partialCustomerName) { if (string.IsNullOrEmpty(partialCustomerName)) throw new ArgumentException("partialCustomerName must be at least one character long"); var criteria = Criteria.Create&lt;Customer, string&gt;(cust =&gt; cust.CustomerName, Criteria.ComparisonOp.Like, partialCustomerName + "%"); int totalRecords; var col = new BusinessObjectCollection&lt;Customer&gt;(); col.LoadWithLimit(criteria, "CustomerName", 0, 20, ref totalRecords); return col; } </code></pre> <p>That should do it! Please award the answer to Till, not me. He did the most research. I just corrected the syntax :)</p> <p>EDIT: After comments below about the ugly API, I will include suggested changes to the method to make it look cleaner (Thanks for your suggestion @GloryDev):</p> <pre><code>public IEnumerable&lt;Customer&gt; FindCustomers(string partialCustomerName) { if (string.IsNullOrEmpty(partialCustomerName)) throw new ArgumentException("partialCustomerName must be at least one character long"); var col = new BusinessObjectCollection&lt;Customer&gt;(); col.LoadWithLimit("CustomerName Like " + partialCustomerName + "%", "CustomerName", 20); return col; } </code></pre> <p>The Second parameter is the field to order by, which is necessary for a fetch with limits to make any sense. Hope this helps.</p>
    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