Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think this is a nice example for <a href="http://martinfowler.com/apsupp/spec.pdf" rel="nofollow">Specification</a> usage.</p> <p>Create object, which will represent <code>zajezd</code> specification:</p> <pre><code>public interface ISpecification&lt;T&gt; { bool IsSatisfiedBy(T value); } public class ZajezdSpecification : ISpecification&lt;Zajezd&gt; { private string _zeme; private string _oblast; private string _stredisko; private string _doprava; private string _strava; private int _cenaOd; private int _cenaDo; public ZajezdSpecification(string zeme, string oblast, string stredisko, string doprava, string strava, int cenaOd, int cenaDo) { _zeme = zeme; _oblast = oblast; _stredisko = stredisko; _doprava = doprava; _strava = strava; _cenaOd = cenaOd; _cenaDo = cenaDo; } public bool IsSatisfiedBy(Zajezd zajezd) { if (!String.IsNullOrEmpty(_zeme) &amp;&amp; zajezd.Zeme != _zeme) return false; if (!String.IsNullOrEmpty(_oblast) &amp;&amp; zajezd.Oblast != _oblast) return false; // ... verify anything you want return _cenaOd &lt; zajezd.CenaOd &amp;&amp; zajezd.CenaOd &lt; _cenaDo; } } </code></pre> <p>and initialize it with values from UI:</p> <pre><code>ZajezdSpecification spec = new ZajezdSpecification( (string)zemeCombo.SelectedValue, (string)oblastCombo.SelectedValue, (string)strediskoCombo.SelectedValue, ... Int32.Parse(cenaDoText.Text) ); </code></pre> <p>Use this specification to filter your collection:</p> <pre><code>var query = from zaj in zajezdy where spec.IsSatisfiedBy(zaj) select zaj; </code></pre> <p>PS try to use English names in your code.</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.
    3. 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