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