C# – The best overloaded method match for XXX has some invalid arguments

asp.netcentity-frameworkentity-framework-5visual studio 2012

I'm a new beginner to the entity framework .

I try to write te following method but i get a compile time error.

 protected static void EntitySQLQuery(AWEntities context)
        {
            string cmd = @"SELECT VALUE c FROM AWEntities.Person AS c WHERE c.FirstName = @FirstName";

            ObjectQuery<Person> persons = new ObjectQuery<Person>(cmd, context);//Error


        }

The best overloaded method match for
'System.Data.Objects.ObjectQuery.ObjectQuery(string,
System.Data.Objects.ObjectContext)' has some invalid arguments

Best Answer

Your AWEntities context object is not recongnized as an ObjectContext. Please check the type of your object. Take a look at definition of ObjectContext and ObjectQuery's constructor

Related Topic