Yanick Rochon
Yanick Rochon

Reputation: 53616

Entity Framework missing ObjectSet methods

I imported a project from SVN, constructed a MSSQL CE 4.0 local database from a script provided with the project, generated the Entity Model using SQL Server CE Toolbox, checked the connexion string, checked the assemblies, but yet some methods are missing from the generated ObjectSet entities.

From Microsoft's site, there should be a method Any<TEntity>(), but I it's not there.

Here's the simple test I'm doing :

using (Dbntities ctx = new DbEntities())
{
   List<User> Users = ctx.Users.All();
}

And Visual Studio 2010 cannot compile because the method All() does not exist.

How do I fix this?

Upvotes: 1

Views: 661

Answers (1)

gdoron
gdoron

Reputation: 150313

Two things:

First: Make sure to add the needed using statement as All is an extension method of IQueryable<T>:

using System.Linq;

Second: Use the All method with the right parameters:

List<User> Users = ctx.Users.All(x => x.Foo == "foo");

Upvotes: 3

Related Questions