0
我在Sharepoint 2010上有三個列表,我有工作代碼來獲取列表並將它們關聯起來。我的問題是大約需要15秒來加載我的網頁。一般來說,我是LINQ to Sharepoint和LINQ的排名初學者。我的問題是:有沒有辦法讓代碼運行得更快?優化LINQ to Sharepoint
SeatingChartContext dc = new SeatingChartContext(SPContext.Current.Web.Url);
EntityList<Seating_chartItem> seatCharts = dc.GetList<Seating_chartItem>("seating_chart");
EntityList<UsersItem> users = dc.GetList<UsersItem>("users");
EntityList<Excluded_usersItem> exusers = dc.GetList<Excluded_usersItem>("excluded_users");
// EntityList<LogsItem> logs = dc.GetList<LogsItem>("logs");
List<Seating_chartItem> seatList = (from seat in seatCharts where seat.Room == 0 where seat.Floor == floor select seat).ToList();
List <UsersItem> usersList = (from user in users select user).ToList();
List <Excluded_usersItem> xusersList = (from xuser in exusers select xuser).ToList();
var results = from seat in seatList
join user in usersList on
seat.User_id equals user.User_id
where seat.Room == 0
where seat.Floor == floor
where !(from xuser in xusersList select xuser.User_id).Contains(user.User_id)
select new
{
sid = seat.Seat_id,
icon = seat.Icon,
topCoord = seat.Top_coord,
leftCoord = seat.Left_coord,
name = user.Name,
phone = user.Phone,
mobile = user.Mobile,
content = seat.Content
};
這段代碼需要的時間令人沮喪,至少可以說。
謝謝。
@BrokenGlass:謝謝,那完全是訣竅。再看一遍我的代碼,很明顯我寫了兩個大章節。再次感謝。 – Corey 2011-05-04 20:01:38