entity framework 4 查出的数据循环调用了
2个实体,一个article,一个user,我要查article,但是article里有user,所以user查出来了,但是user里又有article集合,所以artclie又查出来了,如此反复,内存溢出,
public partial class article
{
public int id { get; set; }
public string title { get; set; }
public string cont { get; set; }
public Nullable<int> uid { get; set; }
public System.DateTime addtime { get; set; }
public Nullable<int> colid { get; set; }
public virtual user user { get; set; }
public virtual column column { get; set; }
}
public partial class user
{
public user()
{
// this.roleusers = new HashSet<roleuser>();
// this.articles = new HashSet<article>();
}
public int id { get; set; }
public string email { get; set; }
public string uname { get; set; }
public string upass { get; set; }
public virtual ICollection<roleuser> roleusers { get; set; }
public virtual ICollection<article> articles { get; set; }
}
public List<article> PageArts(int start, int limit, out int total)
{
var ll =
_ent.articles.OrderByDescending(o => o.id)
.Skip(start)
.Take(limit).ToList();
total = _ent.articles.Count();
return ll;
}