System.InvalidOperationException:“This MySqlConnection is already in use. See https://fl.vu/mysql-conn-reuse”

出错

var applicationform = db.ApplicationForm.Where(x => applicationformids.Contains(x.id));
            foreach (var item in applicationform)
            {
    var supply = realNeedApplyList.Single(x => x.applicationformid == item.id);//这里出错
。。。。。
}

解决办法加.ToList()

var applicationform = db.ApplicationForm.Where(x => applicationformids.Contains(x.id));
            foreach (var item in applicationform.ToList())
            {
    var supply = realNeedApplyList.Single(x => x.applicationformid == item.id);
。。。。。
}

 

posted @ 2021-08-22 19:27  lunawzh  阅读(837)  评论(0编辑  收藏  举报