我編輯我的帖子,因爲假設3方法返回數據庫表中的行 表是:docTags,標記和文檔docTags是中間表 一個文檔(文檔)可以有多個標籤和一個標籤可以屬於許多文檔 我怎麼能得到:TagKey =「123」其中docTags.Add(新配置(1,1)); 類節目 {相交兩個列表<>
static void Main(string[] args)
{
}
}
public class Configuration
{
public int DocID { get; set; }
public int TagID { get; set; }
public string Name { get; set; }
public string DocKey { get; set; }
public string TagKey { get; set; }
public Configuration(int _docId,string _name, string _docKey)
{
DocID = _docId;
Name = _name;
DocKey = _docKey;
}
public Configuration(int _tagId,string name, string _dockey,string _tagKey)
{
TagID = _tagId;
Name = name;
TagKey = _tagKey;
}
public Configuration(int _tagId, int _docId)
{
TagID = _tagId;
DocID = _docId;
}
public static List<Configuration> getDocType()
{
List<Configuration> docs = new List<Configuration>();
docs.Add(new Configuration(1,"contract", "xxx"));
docs.Add(new Configuration(2,"Action", "yyy"));
return docs;
}
public static List<Configuration> getTagName()
{
List<Configuration> tags = new List<Configuration>();
tags.Add(new Configuration(1,"contractid", "123"));
tags.Add(new Configuration(2,"SuperDuper", "332123"));
tags.Add(new Configuration(22, "rama", "yyy"));
tags.Add(new Configuration(32, "aktiv", "123456"));
tags.Add(new Configuration(42, "data ","xx764fhx"));
return tags;
}
public static List<Configuration> getDocTags()
{
List<Configuration> docTags = new List<Configuration>();
docTags.Add(new Configuration(1, 2));
docTags.Add(new Configuration(1, 1));
docTags.Add(new Configuration(1, 22));
docTags.Add(new Configuration(2, 2));
docTags.Add(new Configuration(2, 32));
return docTags;
}
}
}
爲什麼「沒有擴展方法」? LINQ是做這件事的顯而易見的方法。 –
好,但如何做到這一點? – Krasimir