Hi,
Is it possible to map an entities properties from different database tables? Say you had the below data model...
[dbo.Albums] [dbo.Songs] [dbo.Artists]
AlbumID int (PK) SongID int (PK) ArtistID int (PK)
AlbumName nvarchar(100) AlbumID int ArtistName nvarchar(100)
. SongName nvarchar(50) .
. Duration int .
. ArtistID int .
. .
Required entity:
public class Album
{
public virtual int AlbumID { get; private set; }
public virtual string AlbumName { get; set; }
public List<Song> songs { get; set;}
}
public class Song
{
public virtual int SongID { get; private set; }
public virtual int AlbumID { get; set; }
public virtual string SongTitle { get; set; }
public virtual int Duration { get; set; }
public virtual ArtistID { get; set; }
public virtual ArtistName { get; private set; } <- from different table, read only
}
I know I should probably be creating an Artists entity and attaching that to the Song entity but if the Artists table had lots of columns and all I needed was the ArtistName what's the point in returning all the extra data across the wire when it's not going to be used or updated? I only want the ArtistName for display purposes only.
Thanks, FJ