I am new to the Entity Framework. I am attempting to get a count from a LINQ query that should return 1 result. The count is always 0 though. I know that the data is there and the relationship is sound in the edmx.
Here is the code:
LineItem li = order.LineItems.Where(i => i.ID == lineItemId).FirstOrDefault();
if (li != null)
{
if (li.Notes.Count > 0)
{
// Get note data
}
}
Now ListItem is not null so I am able to get to the count call. Again I have verified that I have my data as my debugging nets the .Where match as "52635 == 52635"
Is there something I am missing here in order to get my count? Or is there any suggestion to how I can debug this problem further?
I am using Entity Framework 4 +
Thanks!
order, the problem is probably there (as alluded to by @DanielAWhite's answer).