简体   繁体   中英

DbContext has been disposed when using nested LINQ

Hello i have a problem which i cannot figure. Can anyone explain what the problem is and how it can be fixed ?

  ///--> get group members
    _adProfiles = groupsIds.Select(self => new Func<IEnumerable<AdProfileDto>>(() =>
    {
         return GetGroupMembersRepository.GetMembers(new GetGroupProfilesRequest { GroupId = self }).Profiles
             .Select(item => new Func<AdProfileDto>(() =>
                {
                 return new AdProfileDto
                   {
                      AccountName = item.AccountName.ToLower(),
                      DisplayName = item.DisplayName,
                      GroupId = self
                     };
                  })).Select(item => item.Invoke()).ToList();
              })).SelectMany(self => self.Invoke()).ToList();

Thank you all .

问题出在数据访问级别,当我从数据库中检索条目时,忘记添加.ToList()了。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM