When I go through the debug of the dataAccessContext after calling the above, I look at an entity called JobNumbers. Inside of that entity, there is another entity called SafetyIssues, which has 2 records instead of 1. They are the exact same record. The database only shows one record, but some how it's pulling the same record twice in the dataAccessContext.

Even when I bind to a listbox later on it shows the same record in the listbox twice. If I click one, they BOTH get selected.

Might be unrelated, but SafetyIssueTotals seems to be declared twice in the JobNumber entity associations.
–
Ocelot20Feb 4 '13 at 18:21

By the way, not sure if this is just there for the sake of having a code example, but checking if the response is null, and if it isn't setting it to a variable is going to run the query twice. You would be better off doing something like var jobNum = query.SingleOrDefault(); if(jobNum == null) { // use jobNum here. }. That way you'll reduce db calls.
–
Ocelot20Feb 4 '13 at 18:24

After doing some more debugging, I have found out that the first part of the code I posted is not involved. This is happening as soon as I create the DataContext. I'll edit my question to show where I first notice it. And good point about the null thing. The SafetyIssueTotals is unrelated to this.
–
DJ BurbFeb 4 '13 at 19:15

edited, for the new discovery that I made. Still puzzling me
–
DJ BurbFeb 4 '13 at 19:23

The two SafetyIssueTotals you see are actually two different tables (one of which doesn't need to be there anymore). They are actually spelled different SafetyIssueTotals and SafetyIssuesTotals, but they are irrelevant to this issue.
–
DJ BurbFeb 4 '13 at 19:26

1 Answer
1

Well, I fixed the issue. The problem was in my dbml code. I think I was calculating my totals before the job got a chance to finish loading so, when I moved my calculation to after the job finished loading, it worked. Here's the code that I changed: