dc

dc

  • NA
  • 663
  • 0

C# linq question

Oct 29 2012 2:51 PM
In the code listed below for a C# 2010 application, the  intGoodTransCount value ends up being 0 too many times. Thus can you tell me if there is anything wrong with the linq statement below? If not, then I have a problem with the actual selection criteria I am using.
int intGoodTransCount = 0;
var varGoodTransCount = (from t in rData.Transactions
  join iw in rData.Workbooks on t.Workbook_ID equals iw.Workbook_ID
  join ip in rData.Packages on iw.PID equals ip.PID
  where (ip.TNum != null)
  && ip.TNum.Length >= 3
  && ip.TNum.Substring(0, 3) == "X54"
  && (t.Complete_Date != null)
  group ip by ip.TNum into g
  select new { TNum = g.Key, Frequency = g.Count() }).FirstOrDefault();
  if  ((varGoodTransCount != null) && (varGoodTransCount.Frequency != null) && (varGoodTransCount.Frequency > 0))
  {
  intGoodTransCount = Convert.ToInt32(varGoodTransCount.Frequency);
  }
  else
  {
  intGoodTransCount = 0;
  }

Answers (1)