I have a Linq join and have populated viewmodel using that join. On running, there is an error on that join saying
There is already an open DataReader associated with this Command which must be closed first
Below is my join
public List<GallerySisterComanyVM> GetAllGallery()
{
var list = (from GI in uow.Repository<GalleryImage>().GetAll()
join SC in uow.Repository<SisterCompany>().GetAll() on GI.SisterCompanyId equals SC.SisterCompanyId
select new GallerySisterComanyVM
{
GalleryImageId=GI.GalleryImageId,
Status=GI.Status,
Image=GI.Image,
SisterCompanyName=SC.SisterCompanyName
}).OrderByDescending(x=>x.GalleryImageId).ToList();
return list;
}
Check your web.config or .json secrets configuration file for the SQL connection string used to start the Context and look for the "MultipleActiveResultSets=True" bit.
If this doesn't exist, try adding it to the end of your SQL string and try again.