我有一个左连接来执行。并从中获取整个对象。但是,当项目集合为空时,它会超时。选择(x => x.object);
public Tuple<td_GroupLicense, List<td_UserGroupMap>> ReturnActiveLicenseInfo(int GroupID)
{
Tuple<td_GroupLicense, List<td_UserGroupMap>> Tuple;
#endregion
var GroupUserLicense = from grp in Context.td_Groups
from lic in Context.td_GroupLicenses
.Where(x => grp.IdGroup == x.GroupID && x.GroupID == GroupID)
from ugm in Context.td_UserGroupMaps
.Where(x => grp.IdGroup == x.GroupID && x.GroupID == GroupID)
.DefaultIfEmpty()
select new { GL = lic, UGM = ugm };
td_GroupLicense License = GroupUserLicense.Select(x => x.GL).Distinct().SingleOrDefault();
List<td_UserGroupMap> UserMaps = GroupUserLicense.Select(x => x.UGM)
.OfType<td_UserGroupMap>()
.DefaultIfEmpty().ToList();
Tuple = new Tuple<td_GroupLicense, List<td_UserGroupMap>>(License, UserMaps);
return Tuple;
}
当我进行连接然后
中的行List<td_UserGroupMap> UserMaps = GroupUserLicense.Select(x => x.UGM)
.OfType<td_UserGroupMap>()
.DefaultIfEmpty().ToList();
由于UGM
中的集合GroupUserLicense
为空,因此超时。它无法进行操作。我想将License和Usegroupmaps的左连接结果放入相应的对象中。但是Right表为null,因此发生超时。如何克服这个?为什么会这样?