Mutliple Linq Querys to Dictionary
<p>I need to create a library with a list of physicians, their id, and a count 
of 
admissions. I have the linq query working how I want:</p>

<pre><code>var phs = from cg in Context.CareGivers  

                          join cgg in ..
                          join o in ..
                          where ..
                          select new
                          {
                              person = ..,
                              internal_id = ..                                                              
                          };  
</code></pre>

<p>So I added a class that grabs all three.</p>

<p>Back to the program I have this going on after the query:</p>

<p>Added class:</p>

<pre><code>class PhysicianDic
{
    public String physician { get; set; }
    public int id { get; set; }
    public int adm { get; set; }

    public PhysicianDic(String physician_set, int id_set, int adm_set)
    {
        this.physician = physician_set;
        this.id = id_set;
        this.adm = adm_set;
    }
}

Dictionary&lt;string, List&lt;PhysicianDic&gt;&gt; data = new Dictionary&lt;string,   List&lt;PhysicianDic&gt;&gt;();
String phys = string.Empty;
int int_id = 0;
int adm = 0;




PhysicianDic physician = new PhysicianDic(phys,int_id, adm);

var visits1 = (from v in Context.Visits where v.adm_ts &gt;= start &amp;&amp; v.adm_ts &lt; end select v); //grabs admissions from date range

    foreach (var cg in phs)
    {
        foreach (var v in visits1.Cast&lt;PhysicianDic&gt;())
        {
          adm++;
        }

        string key = phys;
        PhysicianDic pd = new PhysicianDic(phys, int_id, adm);

        if (data.ContainsKey(key))
        {
            data[key].Add(pd);
        }
        else
        {
            data.Add(key, new List&lt;PhysicianDic&gt; { pd });
        }                    
    }

    foreach (KeyValuePair&lt;string,List&lt;PhysicianDic&gt;&gt; kvp in data.OrderBy(kvp =&gt; kvp.Key))
    {
        try
        {
            int admissions = kvp.Value.Count();
            workbook.AddCell(r, 1, kvp.Key);
        }
        catch
        {
        }
    }
</code></pre>

<p>Am I doing this right? Or should I be trying to get the date range with Linq within the loop?</p>
