Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

'System.Linq.IQueryable' does not contain definition for 'Where'
craigrichards
#1 Posted : Monday, October 14, 2013 5:54:30 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/28/2011(UTC)
Posts: 10
Location: Australia

Was thanked: 1 time(s) in 1 post(s)
I have a build issue around the following code. For somereason it now can't find the Where extension method.

public IEnumerable<CPIRate> All(Expression<Func<CPIRate, bool>> filter = null)
{
var cpiRates = DB.CPIRates.Include(x => x.Type);

if (filter != null)
{
cpiRates = cpiRates.Where(filter);
}

return cpiRates.ToList();
}

Remco
#2 Posted : Monday, October 14, 2013 6:11:42 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,000

Thanks: 932 times
Was thanked: 1259 time(s) in 1172 post(s)
Hi, thanks for sharing this issue.

Can you provide some more information about the workings of the 'Include' method? Is this a custom built extension returning an IQueryable, or a tool from a 3rd party framework?


Cheers,

Remco
craigrichards
#3 Posted : Monday, October 14, 2013 6:48:46 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/28/2011(UTC)
Posts: 10
Location: Australia

Was thanked: 1 time(s) in 1 post(s)
Hi Romco,
This method is in System.core in the .net 4.0 framework. Hope that helps.
Remco
#4 Posted : Monday, October 14, 2013 7:03:24 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,000

Thanks: 932 times
Was thanked: 1259 time(s) in 1172 post(s)
Hi,

The closest method I can find is http://msdn.microsoft.com/en-us/library/gg696450(v=vs.103).aspx. Is this the one the code is calling?

As this is an entity framework method, I'm wondering if this may be related to an issue with code generated from the database.

Can you please help by answering the following questions?

- Does this appear consistently, or is it intermittent?
- Has NCrunch ever built this project successfully?
- If this solution is being shared across a team with others using NCrunch, do they experience the same issue?
- Have you tried placing NCrunch in compatibility mode for this solution?
- Does the project build correctly if you browse to the workspace NCrunch has created for it (click on failing project in Tests Window, go to Advanced->Browse to workspace), then run MSBuild.exe against the generated project file in this workspace?

I'm not sure if your time permits this - but if there's any chance you can build a reproduction of the issue, I'm certain I can provide a solution to this quickly.


Thanks!

Remco
craigrichards
#5 Posted : Monday, October 14, 2013 11:22:16 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/28/2011(UTC)
Posts: 10
Location: Australia

Was thanked: 1 time(s) in 1 post(s)
The method i am calling is below. I application compiles and runs ok. It looks like the type namespaces are getting messed up somehow.

Yes NCrunch was working ok. I did just upgrade in the last couple of days to the latest and it has stopped working.
No one else in the team is using NCrunch. I am the pusher here.
I did try all the compatability setting and it was still no good.
No the project will not build against the version in the workspace.


public static IQueryable<TSource> Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)

CPIRates\Entities\CPIRates.cs (30)#1: Argument 2: cannot convert from 'System.Linq.Expressions.Expression<System.Func<EnergyMarkets.CPIRates.CPIRate,bool>>' to 'System.Func<EnergyMarkets.CPIRates.Persistence.EntityFramework.CPIRate,bool>'

Cheers
Craig
craigrichards
#6 Posted : Tuesday, October 15, 2013 1:10:27 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/28/2011(UTC)
Posts: 10
Location: Australia

Was thanked: 1 time(s) in 1 post(s)
It looks like this is an intermittent issue. I have made a bunch of other unrelated changes and it is now compiling with NCrunch.
craigrichards
#7 Posted : Tuesday, October 15, 2013 1:30:21 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/28/2011(UTC)
Posts: 10
Location: Australia

Was thanked: 1 time(s) in 1 post(s)
Oops, spoke too soon. Another project is failing to build with the following error.

EnergyMarkets\DealCalculations\CPIRatesTests.cs (11)#0: The type or namespace name 'CPIRates' does not exist in the namespace 'EnergyMarkets.CPIRates.Entities' (are you missing an assembly reference?)
Remco
#8 Posted : Tuesday, October 15, 2013 2:21:35 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,000

Thanks: 932 times
Was thanked: 1259 time(s) in 1172 post(s)
I wonder if this may be due to the relationships between the projects involved.

Has NCrunch given you any warnings in regards to assembly referencing? If there is a cross-project dependency that NCrunch hasn't been able to handle (i.e. if you have an absolute project/assembly reference to something in your foreground solution), this can cause some really strange things to happen.

Does a rebuild of your foreground solution, followed by a reset of the NCrunch engine resolve the problem temporarily?

Are you making use of any tools, frameworks, or project file customisations that may manipulate your build process in any way that would be unusual when compared with any of the standard .NET project templates?

Something else that may help to narrow things down ... You mentioned that the problem appeared after upgrading NCrunch to the latest version. Does a downgrade correct the issue? This would help to identify if the problem is some kind of regression or something else that's changed in your codebase.
craigrichards
#9 Posted : Tuesday, October 15, 2013 3:08:20 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/28/2011(UTC)
Posts: 10
Location: Australia

Was thanked: 1 time(s) in 1 post(s)
NCrunch has not gioven me any warnings about assembly referencing. It is a pretty standard project structure and nothing fancy with pre/post build events.

Rebuild of foreground and the a reset od NCruch does nothing useful.

I will try downgrading later on this afternoon.
craigrichards
#10 Posted : Tuesday, October 15, 2013 3:12:40 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/28/2011(UTC)
Posts: 10
Location: Australia

Was thanked: 1 time(s) in 1 post(s)
What I don't understand from the following error is. I browsed to where the EnergyMarkets project is being built by NCrunch. Opened the project and CPIRates correctly does not exist in that namespace. it is in 'EnergyMarkets.CPIRates.Persistence.EntityFramework'. I guess why would this be happening? I did turn off instrumentation and it is still the same.


EnergyMarkets\DealCalculations\CPIRatesTests.cs (11)#0: The type or namespace name 'CPIRates' does not exist in the namespace 'EnergyMarkets.CPIRates.Entities' (are you missing an assembly reference?)
Remco
#11 Posted : Tuesday, October 15, 2013 3:22:44 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,000

Thanks: 932 times
Was thanked: 1259 time(s) in 1172 post(s)
I'm randomly pitching ideas here, as I'm not completely certain of your solution structure :) Is it possible that the compile error only appears cross-project? (for example, it doesn't appear in the project declaring EnergyMarkets.CPIRates.Entities.CPIRates, but instead in another project that uses this type).

I'm wondering if you could take a look at the project file NCrunch has generated in the workspace for the project that is failing. This project file should contain a list of <Reference> tags that are hard assembly references to other projects that NCrunch has built in their own workspaces. This list of references should allow you to lookup which assemblies the project was built against, and subsequently allow you to view the source files used to build these assemblies.

Do the source files look to be correct? Note that you can freely troubleshoot inside the workspaces in order to deduct why the build issue is appearing, as long as you reset the NCrunch engine afterwards to properly re-sync it. If we can find out mechanically why this error is appearing, maybe we can find its cause.
FerrellCarr
#12 Posted : Friday, July 17, 2015 6:20:57 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/17/2015(UTC)
Posts: 1
Location: United States of America

make sure to include this using
using System.Linq
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.063 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download