0
我從WCF服務調用SQL Server 2008中的數據庫的表值函數,並將其結果存儲在LinkedList中。另一方面,當我調用這個服務並獲得這個LinkedList時,所有節點都包含相同的值。我正在使用的代碼如下:(Silverlight)返回LinkedList的WCF服務
public class user
{
public string name;
public string email;
}
public class ChatService : IChatService
{
public LinkedList<user> getOnlineList(string email)
{
LinkedList<user> online = new LinkedList<user>();
JabsBaseDataContext db = new JabsBaseDataContext();
IQueryable<onlineListResult> justOnline = db.onlineList(email);
foreach (onlineListResult r in justOnline)
{
user os = new user()
{
name = r.fname + " " + r.lname,
email = r.email
};
online.AddLast(os);
}
return online;
}
}
chatService.getOnlineListCompleted += onlineRetrieved;
chatService.getOnlineListAsync(email);
void onlineRetrieved(object sender, getOnlineListCompletedEventArgs e)
{
foreach(user us in e.Result)
this.dispatcher.BeginInvoke(() => MessageBox.show(us.name+"\n"+us.email));
}