In a C# 2010 app, I am trying to write a linq to sql statement that is having a problem. The error message says the value is not an instance of an object.
The sql similar is the following:
select COUNT (Trans_id),ip.TNum, from dbo.Trans t inner join dbo.IWbook iw on t.IWork_ID = iw.IWork_ID inner join dbo.IPack ip on ip.PID = iw.PID where ip.TNum = @parameter_value group by ip.TNum
The linq is the following:
var varGoodTransCount = (from t in rData.Trans join iw in rData.Ibooks on t.Ibook_ID equals iw.Ibook_ID join ip in rData.IPacks on iw.PID equals ip.PID where ip.TNum == SPkgID group ip by ip.TNum into g select new { TNum = g.Key, Frequency = g.Count() }).FirstOrDefault();
I am checking for if (varGoodTransCount.frequency != null) when the error is occuring.
Thus can you tell me what could be wrong?