我编辑我的帖子,因为假设 3 个方法从数据库表返回行是docTags
: tags
和docs
. docTags 是一个中间表。一个doc
(文档)可以有多个tags
,一个tag
可以属于多个docs
我怎样才能得到:TagKey = "123"
在哪里 docTags.Add(new Configuration(1, 1));
class Program
{
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;
}
}
}