Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Just forgot the <code>ToList()</code>, to enumerate the ... enumerations when you do <code>o.Select(...)</code></p> <pre><code>var lpYear = ( from a in _ds.Tables[0].AsEnumerable() join b in LandingPages on a["OFFERINGKEY"].ToString() equals b.Code into c from d in c.DefaultIfEmpty() where DateTime.Parse(a["PURCHASEDATE"].ToString()) &gt;= DateTime.Parse("January 1, " + year) where DateTime.Parse(a["PURCHASEDATE"].ToString()) &gt;= DateTime.Parse("December 31, " + year) where LandingPages.Any(x =&gt; x.Code == a["OFFERINGKEY"].ToString()) orderby d.Title select new { title = d.Title, url = d.URL, price = a["PRICE"], purchased = a["PURCHASEDATE"].ToString() }).GroupBy(o =&gt; o.title) .Select(g =&gt; new { total = g.Sum(p =&gt; decimal.Parse(p.price.ToString())), count = g.Count(), title = g.Key, url = g.Select(p=&gt;p.url).Distinct().Single(), code = g.Select(p=&gt;p.code).Distinct().Single() } ); </code></pre> <p>In pure LINQ:</p> <pre><code>var lpYear = from o in (from a in _ds.Tables[0].AsEnumerable() join b in LandingPages on a["OFFERINGKEY"].ToString() equals b.Code into c from d in c.DefaultIfEmpty() where DateTime.Parse(a["PURCHASEDATE"].ToString()) &gt;= DateTime.Parse("January 1, " + year) where DateTime.Parse(a["PURCHASEDATE"].ToString()) &gt;= DateTime.Parse("December 31, " + year) where LandingPages.Any(x =&gt; x.Code == a["OFFERINGKEY"].ToString()) orderby d.Title select new { title = d.Title, url = d.URL, price = a["PRICE"], purchased = a["PURCHASEDATE"].ToString() }) group o by o.title into g select new { total = g.Sum(p =&gt; decimal.Parse(p.price.ToString())), count = g.Count(), title = g.Key, url = (from p in g select p.url).Distinct().Single(), code = (from p in g select p.code).Distinct().Single() }; </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.
 

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