Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not sure how you get to compile your code example above.</p> <p>In your <code>myObj</code> object, the <code>received</code> property is an <code>int</code>, yet you are evaluating it against a <code>bool</code> which should cause this line <code>o.received != true</code> to results in an error <code>Cannot apply operator '!=' to operands of type 'int' and 'bool'</code>.</p> <p><strong>To Check the SQL</strong><br> Once the code compiles use <a href="http://weblogs.asp.net/zeeshanhirani/archive/2008/04/18/how-to-use-profiler-with-linq-to-sql-queries.aspx" rel="nofollow">SQL Profiler</a> to see what SQL is generated.</p> <p>That will show you the constructed SQLs</p> <p><strong>Benchmarking</strong><br> The below is a very crude description of only <strong><em>one possible</em></strong> way you can benchmark your code execution.</p> <p>Wrap your code into a method, for example:</p> <pre><code>public void TestingOperationOneWay() { int[] list; /* Populate list with a bunch of id numbers found in myOBjs */ myCont data = new myCont(); myObj ob = data.myObjs.Where(o =&gt; o.parent == "number1"); foreach(int i in list) { ob.First(o =&gt; o.id == i &amp;&amp; o.received != true).received = true; } } </code></pre> <p>And:</p> <pre><code>public void TestingOperationAnotherWay() { int[] list; /* Populate list with a bunch of id numbers found in myOBjs */ myCont data = new myCont(); foreach(int i in list) { data.myObjs.First(o =&gt; o.parent == "number1" &amp;&amp; o.id == i &amp;&amp; o.received != true).received = true; } } </code></pre> <p>Crate a method which iterates x amount of times over each method using the <code>Stopwatch</code> similar to this:</p> <pre><code>private static TimeSpan ExecuteOneWayTest(int iterations) { var stopwatch = Stopwatch.StartNew(); for (var i = 1; i &lt; iterations; i++) { TestingOperationOneWay(); } stopwatch.Stop(); return stopwatch.Elapsed; } </code></pre> <p>Evaluate the results similar to this:</p> <pre><code>static void RunTests() { const int iterations = 100000000; var timespanRun1 = ExecuteOneWayTest(iterations); var timespanRun2 = ExecuteAnotherWayTest(iterations); // Evaluate Results.... } </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.
    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