Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Lets start by getting the average time between B's start and finish:</p> <p>1) You first need the time difference between the start and finish of each B object so you would do this:</p> <pre><code>List&lt;TimeSpan&gt; timeSpans = new List&lt;TimeSpan&gt;(); foreach (B myB in BList) { TimeSpan myTimeSpan = myB.CompletedDate.Subtract(myB.CreatedDate); timeSpans.Add(myTimeSpan); } </code></pre> <p>2) You now need to get the average of this. You can do this by using lambda expressions:</p> <pre><code>//This will give you the average time it took to complete a task in minutes Double averageTimeOfB = timeSpans.average(timeSpan =&gt; timeSpan.TotalMinutes); </code></pre> <p>You can now do the same thing to get the average time between A's start and B's finish as follows:</p> <p>1)Get the time difference for A's start date and each of B's completion date:</p> <pre><code> List&lt;TimeSpan&gt; timeSpans_2 = new List&lt;TimeSpan&gt;(); foreach (B myB in BList) { TimeSpan myTimeSpan = myB.CompletedDate.Subtract(objectA.CreatedDate); timeSpans_2.Add(myTimeSpan); } </code></pre> <p>2) Get the average of these time differnces exactly like the one above:</p> <pre><code>//This will give you the average time it took to complete a task in minutes Double averageTimeOfAandB = timeSpans_2.average(timeSpan =&gt; timeSpan.TotalMinutes); </code></pre> <p>And you're done. I hope that this helps. Please note that this code has not been tested.</p> <p>EDIT: Remember that LINQ uses Lamda Expressions but is more of syntactic sugar (don't know much about the implementation so I hope you don't hold it against me). And also you could wrap the implementaions I provide in methods so that you can call them multiple times for a List of A objects.</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. This table or related slice is empty.
    1. 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