Code First 上下文条件
Code First Context Conditions
public class Article
{
public List<Category> _ArticleCategory;
public Article()
{
_ArticleCategory = new List<Category>();
}
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ArticleID { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string Content { get; set; }
public int Viewed { get; set; }
public DateTime LastUpdatedDate { get; set; }
public bool IsDeleted { get; set; }
public virtual List<Category> Categories { get; set; }
public virtual List<Tag> Tags { get; set; }
public virtual List<Comment> Comments { get; set; }
}
// I want to take Articles which has more than 1 Category
var result = _context.Articles.Where(a => a.Categories.Count > 1).ToList();
有我的文章 Class 和我的代码 Articles.There 我从 _Context 或其他地方没问题。它给了我所有的文章。
我怎样才能为此创造条件?
谢谢大家..
谢谢大家..
我解决了问题..
public virtual List<Category> Categories { get; set; }
public virtual List<Tag> Tags { get; set; }
public virtual List<Comment> Comments { get; set; }
//this.Configuration.LazyLoadingEnabled = false;
当我想再次使用虚拟列表 options.Thanx 时,我应该打开这个 属性.. 快乐编码:)
public class Article
{
public List<Category> _ArticleCategory;
public Article()
{
_ArticleCategory = new List<Category>();
}
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ArticleID { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string Content { get; set; }
public int Viewed { get; set; }
public DateTime LastUpdatedDate { get; set; }
public bool IsDeleted { get; set; }
public virtual List<Category> Categories { get; set; }
public virtual List<Tag> Tags { get; set; }
public virtual List<Comment> Comments { get; set; }
}
// I want to take Articles which has more than 1 Category
var result = _context.Articles.Where(a => a.Categories.Count > 1).ToList();
有我的文章 Class 和我的代码 Articles.There 我从 _Context 或其他地方没问题。它给了我所有的文章。 我怎样才能为此创造条件? 谢谢大家..
谢谢大家.. 我解决了问题..
public virtual List<Category> Categories { get; set; }
public virtual List<Tag> Tags { get; set; }
public virtual List<Comment> Comments { get; set; }
//this.Configuration.LazyLoadingEnabled = false; 当我想再次使用虚拟列表 options.Thanx 时,我应该打开这个 属性.. 快乐编码:)