1

I have a model (M) that contains two tables(A and B). When I run the code from my MVC application to get the rows from (A) like this:

var context =new ClaimsHistorical();
context.CommandTimeout = 120;
IList<ClaimsSLAMonth> list = context.ClaimsSLAMonths.Where(x=>x.timeperiod == "2012-03").ToList();
var final = list.Select(c => new[]{
            c.branch.ToString().Trim(), c.NLPR_SLA.ToString() ?? null, c.NLPR_count.ToString() ?? null, c.NLPR_AvgLocktime.ToString() ?? null, c.NLPR_PIn.ToString() ?? null, c.NLPR_POut.ToString() ?? null,
            c.NLGA_SLA.ToString() ?? null, c.NLGA_count.ToString() ?? null, c.NLGA_AvgLocktime.ToString() ?? null, c.NLGA_PIn.ToString() ?? null, c.NLGA_POut.ToString() ?? null
        });

When I set a breakpoint for the list.Select to check the command it gives me the SQL which works in SSMS

It returns 0 rows (no errors, warnings, messages). I copied the SQL query that is being "executed" by the EF and pasted it to SQL Server Management Studio, it returns me the 5 or so rows.

Also when I run the exact same code except I substitute the table name to (B) I get the rows correctly. I tried to recreate the Model and it still returns nothing. Am I missing something obvious, or is there something seriously wrong?

14
  • 2
    You said you took the SQL that EF "executed", so you ran the SQL profiler, copied the generated SQL statement, and ran it in SSMS? Correct? Commented Apr 12, 2012 at 20:36
  • 1
    What @M.Babcock means is did you use the actual statement from SQL Profiler, or did you use the statement displayed by the debugger when you examine the query? Commented Apr 12, 2012 at 20:40
  • Yep. Put a breakpoint at the moment it was selecting stuff, looked at the object properties (where it has the connection string and the command string) copied it to SSMS and it gave me the rows i wanted. Commented Apr 12, 2012 at 20:41
  • What's your datatype? I'm wondering if your data might be padded (like you used a char datatype) so the exact compare fails. Maybe try a .Startswith() Commented Apr 12, 2012 at 20:51
  • @m4tt1mus Same thing 0 rows.... Commented Apr 12, 2012 at 20:52

1 Answer 1

2

So apparently rebooting the computer fixed the problem?

If anyone has any possible reasons for this (caches, settings, anything) that would help in preventing this from happening again.

Sign up to request clarification or add additional context in comments.

1 Comment

Is there another way to do this that you know off?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.