title: Group by multiple items in list then sum and average c#
body: <p>I need to perform quite a complicated query and having difficulty doing it. what I have is a list of objects called LiquidityBuilder:</p>
  
  <pre><code>public class LiquidityBuilder
  {
      private string _lp;
      private string _timezone;
      private int _size;
      private bool _ask;
  
      public string LP
      {
          get { return _lp; }
      }
  
      public int Size
      {
          get { return _size; }
      }
  
      public string Timezone
      {
          get { return _timezone; }
      }
  
      public bool Ask
      {
          get { return _ask; }
      }
  
      public LiquidityBuilder(string lp, string timezone, int size, bool ask)
      {
          _lp = lp;
          _timezone = timezone;
          _size = size;
          _ask = ask;
      }
  }
  </code></pre>
  
  <p>The data will look something like this:</p>
  
  <pre><code>LP      Timezone      Size     Ask
  GS       LDN        1000000  True
  GS       LDN        3000000  True
  GS       TOR        2000000  True
  JPM      TOR        1000000  False
  CS       ASIA       1000000  True
  JPM      TOR        1000000  False
  CITI     TOR        2000000  False
  </code></pre>
  
  <p>I'm first trying to group by the "LP" then by "Timezone" then by "Ask" then sum the sizes. So example,</p>
  
  <pre><code>GS     (Ask)
  LDN: 4000000
  TOR: 2000000
  </code></pre>
  
  <p>This is what I have:</p>
  
  <pre><code>var groupedLiquidityList = liquidtyTimezoneData
      .GroupBy(u =&gt; u.LP &amp;&amp; u.Timezone &amp;&amp; u.Ask)
      .Select(grp =&gt; grp.ToList())
      .ToList();
  </code></pre>
  
  <p>now I can't group by string's what would also be the most efficient way to do this because performance matters for the application I'm developing..Any suggestions? Thanks!</p>