开发者

linq query works on every machine but mine [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜