0
메신저 기능을 가진 저장소에서 "붙여 넣기"페치,하지만 내가 붙여 넣기 가져올 때 포함되어야하는 개체 액세스 할 수 없습니다. (Paste.FilterGroup.Ads).저장소를 사용하여 entityframework에 객체를 포함하는 방법은 무엇입니까?
내 저장소 기능 :
public T Find<T>(Expression<Func<T, bool>> predicate) where T : class
{
return Context.Set<T>().FirstOrDefault<T>(predicate);
}
그리고 나는 이것을 시도 내 코드에서
. oPaste = _repository.Find<Paste>(x => x.PasteID == oPaste.PasteID);
if (oPaste.FilterGroup != null)
{
_log.Debug("FilterGroup: " + oPaste.FilterGroup.Name);
if (oPaste.FilterGroup.Ads != null && oPaste.FilterGroup.Ads.Count() > 0)
{
_log.Debug("FINALLY");
}
else
{
_log.Debug("Paste " + oPaste.PasteID + " has no ads");
}
}
else
{
_log.Debug("Paste " + oPaste.PasteID + " has no filtergroup");
}
편집 : 붙여 넣기 클래스는 교체해야합니다
public virtual FilterGroup FilterGroup { get; set; }
FilterGroup 클래스
public virtual IEnumerable<Ad> Ads { get; set; }
감사합니다! 그게 문제를 해결했습니다! –