linq query works on every machine but mine [closed]
So, I have a simple linq query. Other programmers (all on Win7, VS2010) can run the select without issue. I can use SQL Profiler on my machine to hit the server db (we are all hitting the same SQL Server 2008 db on a development server) and see the actual query works in SQL Server Mgmt studio from my machine, but the IQueryable object returns 0 results.
We are all using the same exact code base (everything is checked into Hg and we are all synched). I have restarted my machine and the server the db resides on in case there was some caching going on.
If I remove the where clause I actually get results back. We are all at a loss. Anyone have any bright ideas???
Here is the code in case you want to see but I don't think it matters in this case:
IQueryable<MOffice> offices = (from returnData in entityModel.MOffices
开发者_开发百科 where returnData.HiringProjectCoordinator == true
select returnData).Take((int)topCount);
return offices.ToList();
Try this
var results = entityModel.MOffices
.Where(x=>x.HiringProjectCoordinator == true)
.OrderBy(x=>x.Something)
//.Take(int.Parse(topCount))
.ToList();
int count = results.Count();
return results;
Inspect that count is as you expect. Remove the comment as needed.
- Does the query work on LinqPad?
- Confirmed everyone is referencing the same database? For sure? i.e. change one particular record firstName to 'foo' to determine.
- Does a similar query to another table act same?
Use LinqPad then inspect the generated SQL statement of your LINQ.
精彩评论