我有两个型号,其是如何获得连接表数据实体框架
public class Post
{
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string ShortDescription { get; set; }
public string PostImage { get; set; }
public string Thumbnail { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime? PublishedDate { get; set; }
public string CreatedBy { get; set; }
public virtual ICollection<Category> Categories { get; set; }
}
public class Category
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Post> Posts { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
}
和产生CategoryPosts
表。
这是我的问题:我想从CategoryPosts
表中获取数据来计算热门类别。我如何获得这些数据?什么是最好的方式来做到这一点?
如果需要,作为一个企业实体,把它定义为一个商业实体(定义类) – Amit
反正是有解决这个问题的LINQ?我为什么要定义另一个班级? – sercanD
A.为什么不呢? B.因为如果你想使用这样的实体的虚构,定义它 – Amit