Die Eigenschaften-Ausdruck ist nicht gültig. Der Ausdruck soll darstellen, eine Eigenschaft

Habe ich diese zwei Entitäten

public class Song : IPathHavingEntity
    {
        public int Id { get; set; }
        [Required]
        public string Path { get; set; }
        [Required]
        public virtual Album Album { get; set; }
        [Required]
        public int TrackNumber { get; set; }
    }

public class Album : IPathHavingEntity
    {
        public int Id { get; set; }
        [Required]
        public string Path { get; set; }
        public virtual IEnumerable<Song> Songs { get; set; }
        [Required]
        public int AlbumNumber { get; set; }
    }

Path definiert wird, in der IPathHavingEntity - Schnittstelle.

In my Seed-Methode, die ich möchte hinzufügen eines Songs auf die Songs Tabelle nur, wenn es nicht vorhanden ist. Aus diesem Grund kann ich überprüfen, dass das album Weg und song-Pfad-Kombination nicht existieren bereits, bevor Sie es so

context.Songs.AddOrUpdate(
    s => new { FilePath = s.Path, AlbumPath = s.Album.Path }, 
    new Song { TrackNumber = 1, Path = "01 Intro.mp3", Album = one });

Das problem ist, ich bekomme diese Fehlermeldung

The properties expression 's => new <>f__AnonymousType0``2(FilePath =
s.Path, AlbumPath = s.Album.Path)' is not valid. The expression should
represent a property: C#: 't => t.MyProperty' VB.Net: 'Function(t) t.MyProperty'. When specifying multiple properties use an anonymous type: C#: 't => new { t.MyProperty1, t.MyProperty2 }' VB.Net: 'Function(t) New With { t.MyProperty1, t.MyProperty2 }'.

Was ist das problem?

Schreibe einen Kommentar