C# linq group by error

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have the following linq to sql statement that I want to use in a C# 2008 application that connects to a sql server 2008 r2 database.<br/>
<br/>
var varGoodTransCount = (from t in rData.Trans<br/>
join iw in rData.Ibooks on t.Ibook_ID equals iw.Ibook_ID<br/>
join ip in rData.IPacks on iw.PID equals ip.PID<br/>
where ip.TNum == SPkgID
<br/>
group ip by ip.TNum into g<br/>
select new { TNum = g.Key, Frequency = g.Count() }).FirstOrDefault();
The line of code that has the problem is
If (varGoodTransCount.Frequency != null)
When I try to reference varGoodTransCount.Frequency, the error message says this is not an instance of an object.<br/>
Thus can you tell me what is wrong and how I can fix the problem?

View the full article
 
Back
Top