我正在與前一個問題的幫助,但再叫要求與其相關的新的問題,但考慮到代碼中,我碰到一個錯誤:沒有添加linq語法的定義?
public void AddPersonToCommunity(string person, string communityName)
{
var result = communities.Where(n => String.Equals(n.CommunityName, communityName)).FirstOrDefault();
if (result != null)
{
result.Add(new Person() { PersonName = person }); //no definition for add?
}
}
你可以在這裏看到前面的問題的更多細節: relationships in rest?
如果我這樣做var result = communities;
結果會有添加的定義,所以我不知道發生了什麼事情?
這將工作,而不是firstordefault你使用tolist,以便結果是一個集合,而不是一個單一的實體。儘管添加到數據庫中會有什麼進展? – 2012-04-06 22:56:22