Compile error when calling ToList() when accessing many to many with Linq To Entities
- by KallDrexx
I can't figure out what I am doing wrong. I have the following method:
public IList<WObject> GetRelationshipMembers(int relId)
{
var members = from r in _container.ObjectRelationships
where r.Id == relId
select r.WObjects;
return members.ToList<WObject>();
}
This returns the following error:
Instance argument: cannot convert from 'System.Linq.IQueryable<System.Data.Objects.DataClasses.EntityCollection<Project.DomainModel.Entities.WObject>>' to 'System.Collections.Generic.IEnumerable<Project.DomainModel.Entities.WObject>'
How can I convert the EntityCollection to a list without lazy loading?