Linq to sql result should find a value
-
Tuesday, February 12, 2013 5:11 PM
In a C# 2008 windows application, I have the following linq to sql statement that points to a sql server 2008 r2 database. The following query returns null. However there is a null value retuned and but there a valid records that can be selected from the linq query listed below.
string SubmissionPkgID = 'valid string value'.
var varGoodTransCount = (from t in rData.Transactions
join iw in rData.Ibooks on t.ImportID equals iw.ImportID
join ip in rData.IPackages on iw.PID equals ip.PID
where (ip.trc_num != null)
&& ip.trc_num == SubmissionPkgID
group ip by ip.trc_num into g
select new { trc_num = g.Key, Frequency = g.Count() }).FirstOrDefault();*Note: SubmissionPkgID does contain a valid value.
Thus can show me some code that will make this query work?
- Edited by wendy elizabeth Tuesday, February 12, 2013 5:12 PM
All Replies
-
Tuesday, February 12, 2013 9:35 PM
Hi Wendy;
The query looks like it should be working.
In the Transactions table where you have a valid SubmissionPkgID do you also have records in the Ibooks and IPackages tables where Transaction.ImportID has a value that is also in Ibooks.ImportID are equal and also Transaction.PID with a record in IPackages.PID? If not then this would be the reason why the results is null.
Fernando (MCSD)
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".- Marked As Answer by wendy elizabeth Wednesday, February 13, 2013 3:39 AM

