我試着標籤添加到組,所以當我想補充一組我可以關聯的標籤添加到它。我試圖做的是能夠返回按標籤過濾的組列表。類鏈接WCF
List<Group> Groups = new List<Group>();
List<Tag> tags = new List<Tag>();
public void AddTagtoGroup(Group group, Tag tag)
{
group.GroupName(tag.Add);
return Groups with tags or tags with groups
}
這是團體和標籤數據契約:
[DataContract(Name = "Group")]
public class Group
{
public Group() // not sure if this has to have a datamember
{
Tags = new List<Tag>();
}
[DataMember(Name = "GroupName")]
public string GroupName { get; set; }
public List<Tag> Tags { get; set; } // datamember or not?
}
[DataContract(Name = "Tag")]
public class Tag
{
[DataMember(Name = "TagName")]
public string TagName { get; set; }
}
如果您希望讓WCF消息中包含的'Tags'屬性通過線路發送,那麼**是**,它必須用'[[ DataMember]屬性,如果你用'[DataMember]'屬性修飾你的類,那麼**只有標有'[DataMember]'**的內容纔會被序列化爲WCF信息。 – 2012-04-06 20:42:09
怎麼來一個group.GroupName tag.Add)可以添加標籤。o_O – wonde 2012-04-06 22:14:50