【发布时间】:2013-08-16 09:07:16
【问题描述】:
如果我有像
这样的模型类[Table("MTag")]
public class Tag
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int TagId { get; set; }
public string TagLabel { get; set; }
public virtual ICollection<TagRef> RefTags { get; set; }
}
[Table("TagRef")]
public class TagRef
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int TagRefId { get; set; }
public virtual Tag Tag { get; set; }
public virtual ICollection<Post> Posts { get; set; }
}
[Table("Post")]
public class Post
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int PostId { get; set; }
public UserProfile User { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string PostGuid { get; set; }
public string Make { get; set; }
public string Model { get; set; }
public virtual ICollection<MTagRef> Tags { get; set; }
public string ImageFileName { get; set; }
public int Price { get; set; }
public int ImageWidth { get; set; }
public int ImageHeight { get; set; }
}
可以通过哪些查询来选择所有匹配的帖子?能否请您提示一下,如果我有 Car、Mobile 等标签,如何设置查询?
【问题讨论】:
-
请您详细说明选择所有匹配的帖子?这里的匹配是基于什么条件的?
-
我想选择所有匹配标签的帖子,例如车辆或电子产品。
-
“车辆或电子产品”是什么意思?标签名称??
标签: c# .net entity-framework tags entity