I am learning Entity Framework 4 from book.
And I try to make some Query with Entity SQL like this :
using (var context = new BAEntities())
{
string str = "SELECT VALUE c " +
"FROM BAEntities.Contacts " +
"AS c " +
"WHERE c IS NOT OF(BAModel.Customer)";
ObjectQuery<Contact> qry = context.CreateQuery<Contact>(str);
Console.WriteLine(qry.Count());
}
My query purpose is to take all Objects of Contact Type but not of Customer Type. Where, Customer inherits from Contact
But I got the following error :
Type 'BAModel.Customer' could not be found. Make sure that the required schemas are loaded and that the namespaces are imported correctly. Near type name, line 1, column 64.
But, If I do query with LINQ to Entities like this :
ObjectQuery<Contact> qry = context.Contacts.Where(c => !(c is Customer));
then program can Run correctly.
So, why in Entity SQL BAModel.Customer
is not found, whereas I ran the code within the same project in which the model is located.
Please help me in this.
Thanks in Advance.