C# 4.0 当我尝试进行紧急加载时,我得到一个null collection错误
我尝试通过以下方式进行快速加载:C# 4.0 当我尝试进行紧急加载时,我得到一个null collection错误,c#-4.0,entity-framework-5,eager-loading,C# 4.0,Entity Framework 5,Eager Loading,我尝试通过以下方式进行快速加载: lstResultado = miContexto.Videos .Include(v => v.Series.Select(s => s.Episodios)) .Include(v=> v.VideosVersiones) .Include(v => v.Generos
lstResultado = miContexto.Videos
.Include(v => v.Series.Select(s => s.Episodios))
.Include(v=> v.VideosVersiones)
.Include(v => v.Generos).ToList<Videos>();
谢谢。VideosVersions中是否有相关数据?是的,有些视频(不是所有视频,但有一些视频)有版本,因此表VideosVersions中有将视频与版本连接起来的寄存器。您不介意包含所有必需的代码(缺少类和正确的变量声明)吗这样我们就可以轻松地测试它并快速提供帮助,而无需花费不必要的时间?谢谢
public partial class Videos
{
public Videos()
{
this.Series = new HashSet<Series>();
this.VideosPersonas = new HashSet<VideosPersonas>();
this.VideosVersiones = new HashSet<VideosVersiones>();
this.Generos = new HashSet<Generos>();
}
public long IDVideo { get; set; }
public string Titulo { get; set; }
public string Version { get; set; }
public Nullable<short> Duracion { get; set; }
public Nullable<short> Anyo { get; set; }
public bool Favorito { get; set; }
public bool Pendiente { get; set; }
public string Descripcion { get; set; }
public Nullable<long> IDPortada { get; set; }
public long IDTipo { get; set; }
public virtual Ficheros Ficheros { get; set; }
public virtual ICollection<Series> Series { get; set; }
public virtual Tipos Tipos { get; set; }
public virtual ICollection<VideosPersonas> VideosPersonas { get; set; }
public virtual ICollection<VideosVersiones> VideosVersiones { get; set; }
public virtual ICollection<Generos> Generos { get; set; }
}
public partial class VideosVersiones
{
public long IDVersion { get; set; }
public long IDVideo { get; set; }
public long IDEpisodio { get; set; }
public virtual Episodios Episodios { get; set; }
public virtual Versiones Versiones { get; set; }
public virtual Videos Videos { get; set; }
}
public partial class Series
{
public Series()
{
this.Episodios = new HashSet<Episodios>();
}
public long IDSerie { get; set; }
public long IDVideo { get; set; }
public Nullable<short> AnyoInicio { get; set; }
public Nullable<short> AnyoFin { get; set; }
public Nullable<short> NumeroTemporadas { get; set; }
public virtual ICollection<Episodios> Episodios { get; set; }
public virtual Videos Videos { get; set; }
}
public partial class Episodios
{
public Episodios()
{
this.VideosVersiones = new HashSet<VideosVersiones>();
}
public long IDEpisodio { get; set; }
public long IDSerie { get; set; }
public byte Temporada { get; set; }
public byte Episodio { get; set; }
public string Titulo { get; set; }
public Nullable<byte> Anyo { get; set; }
public virtual Series Series { get; set; }
public virtual ICollection<VideosVersiones> VideosVersiones { get; set; }
}