Note that there are some explanatory texts on larger screens.

plurals
  1. POlinQ group by/select - object reference not set to an instance of an object
    primarykey
    data
    text
    <p>I'm trying to create a linQ query which will yield the same outcome as this SQL:</p> <pre><code>SELECT Priority.PriorityKey, Count(Priority.PriorityKey) AS NewPresentingUnits FROM Priority INNER JOIN SupportPeriod ON Priority.PriorityCode = SupportPeriod.PriorityCode WHERE (((SupportPeriod.NewClient)=True) AND ((SupportPeriod.DateAssistanceRequested) Between #1/1/2013# And #2/1/2013#) AND ((SupportPeriod.DateFinished) Between #1/1/9999# And #12/31/9999#)) GROUP BY Priority.PriorityKey; </code></pre> <p>I get the following result when i run the SQL query:</p> <p><a href="https://docs.google.com/file/d/0B6b_N7sDgjmvRlBtT1lZWURERVU/edit?usp=sharing" rel="nofollow">https://docs.google.com/file/d/0B6b_N7sDgjmvRlBtT1lZWURERVU/edit?usp=sharing</a></p> <p>This is the linQ statement:</p> <pre><code> SupportPeriodTableAdapter spTa = new SupportPeriodTableAdapter(); SupportPeriodDataTable dataTables = spTa.GetData(); var test = (from sp in dataTables where (sp.NewClient == true) &amp;&amp; (sp.DateAssistanceRequested &gt;= new DateTime(2013, 1, 1) &amp;&amp; sp.DateAssistanceRequested &lt;= new DateTime(2013, 2, 1)) &amp;&amp; (sp.DateFinished &gt; new DateTime(2013, 2, 1)) group sp by sp.PriorityRow.PriorityKey into groupz select new { Key = groupz.Key, sount = groupz.Count() }); </code></pre> <p>When i try to debug <code>var test</code> i get "object reference not set to an instance of an object" in the results view.</p> <p><a href="https://docs.google.com/file/d/0B6b_N7sDgjmvdGp0bjJCNkE3TTg/edit?usp=sharing" rel="nofollow">https://docs.google.com/file/d/0B6b_N7sDgjmvdGp0bjJCNkE3TTg/edit?usp=sharing</a></p> <p>I'm new to using 'group by' and 'select new' features of linQ, thus i'm having a hard time figuring this out....</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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