Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The .Net Framework exposes a lot of awesome extension methods, like Sum, Average, etc...</p> <p><a href="http://msdn.microsoft.com/en-us/library/bb341635" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb341635</a></p> <p>Example:</p> <pre><code>class Program { static void Main(string[] args) { var sweetList = new List&lt;int&gt; { 4, 123, 5, 23, 42 }; Console.WriteLine("Average: {0}", sweetList.Average()); Console.WriteLine("Sum: {0}", sweetList.Sum()); var listOfCoolObjects = new List&lt;CoolObject&gt;(); listOfCoolObjects.Add(new CoolObject { Name = "1434", NeatValue = 42 }); listOfCoolObjects.Add(new CoolObject { Name = "asdf", NeatValue = 5 }); listOfCoolObjects.Add(new CoolObject { Name = "fgsdfg", NeatValue = 99 }); listOfCoolObjects.Add(new CoolObject { Name = "qwerty", NeatValue = 1345 }); listOfCoolObjects.Add(new CoolObject { Name = "casc", NeatValue = 111 }); Console.WriteLine("Average: {0}", listOfCoolObjects.Average(x =&gt; x.NeatValue)); Console.WriteLine("Sum: {0}", listOfCoolObjects.Sum(x =&gt; x.NeatValue)); } } class CoolObject { public string Name { get; set; } public int NeatValue { get; set; } } </code></pre> <p>In your code, you could do something like this:</p> <pre><code>var sum = (From fdi In db.FoodDiaryItems Where fdi.PersonID = CurrentSiteUser.PersonID And fdi.EntryDate = CurrentDiaryDate).Sum(fdi =&gt; fdi.SomeValueYouWantToSum) </code></pre> <p>I know you're coding in VB, but I don't know VB at all, so excuse any syntax errors in that last code chunk.</p>
    singulars
    1. This table or related slice is empty.
    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