I was using IQueryable and Reflection to select tables dynamically :
IQueryable<object> query = typeof(GWork).GetProperty(tblName).GetValue(context, null) as IQueryable<object>;
if (!string.IsNullOrEmpty(relations) && query != null)
{
relatedEntities = relations.Split(',');
foreach (string relatedEntity in relatedEntities)
{
query.Include(relatedEntity);
}
}
I'm getting the error : IQueryable does not contain a definition for 'Include' and no extension method 'Include' althought I have included System.Data.Entity
I tried to cast the IQueryable<object> to ObjectQuery<object> but the conversion will result in null values
Is this a .Net Framework version problem? My project is currently using version 4.0
Any advices are greatly appreciated!
It's a compilation error because it cannot validate statically that such method exists, besides, Include() is an extension method. You must reference the namespace where this method belongs.
Manage to include this on top of file: