我收到以下錯誤。我GOOGLE了它的一天多時間,但我不能找到確切的解決方案,請幫我謝謝無法將類型'System.Collections.Generic.List <System.Collections.Generic.IEnumerable <xxx>>'隱式轉換爲'System.Collections.Generic.List <xxx>
ERROR: Cannot implicitly convert type
System.Collections.Generic.List<System.Collections.Generic.IEnumerable<ADCO.eJMC.EntityDataModel.ShareholderUser>>
toSystem.Collections.Generic.List<ADCO.eJMC.EntityDataModel.ShareholderUser>
我用下面的代碼
List<ShareholderUser> list = new List<ShareholderUser>();
list = dataContext.EJMCShareholderApprovals
.Include(s => s.Shareholder.ShareholderUsers)
.Where(e => e.EJMCRequestId == requestId)
.Select(s => s.Shareholder.ShareholderUsers
.Where(x => x.AccessMode == true))
.ToList();
我認爲''包括(s => s.Shareholder.ShareholderUsers)'行是多餘的,因爲我們選擇's.Shareholder.ShareholderUsers':無論如何:http://msdn.microsoft.com/en-us/library/ bb738708.aspx – Kobi
@Kobi:我會將其添加爲評論,但我對EF沒有足夠的瞭解,無法自信地陳述它...... –
如果您僅使用所選內容,則無需添加包含。只有當你想*包含*特定的上下文,否則會被延遲加載。 –