0

I try to do the eager loading in this way:

lstResultado = miContexto.Videos
                            .Include(v => v.Series.Select(s => s.Episodios))
                            .Include(v=> v.VideosVersiones)
                            .Include(v => v.Generos).ToList<Videos>();

But I get this error: "The value can't be null. Name of the parameter: collection."

If I use only Include(v => v.Series.Select(s => s.Episodios)) it works fine, but the problem is when I use Include(v=> v.VideosVersiones).

My entities are:

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; }
    }

Thanks.

Davin Tryon
  • 66,517
  • 15
  • 143
  • 132
Álvaro García
  • 18,114
  • 30
  • 102
  • 193
  • Is there related data in `VideosVersiones`? – Tim Aug 11 '13 at 07:37
  • Yes some videos, not all of them, but a few of them, has versions, so in the table VideosVersiones there are registers that joins videos with versions. – Álvaro García Aug 11 '13 at 07:42
  • Wouldn't you mind to include all the required code (missing classes and proper declaration of variables) such that we can easily test it and provide help quickly without spending time unnecessarily? Thanks. – varocarbas Aug 11 '13 at 09:46

0 Answers0