I can not manage to select the data in a flat structure and detailed information in a array of the same structure together in one select.
If I do it one after the other, the performance is pretty bad.
Perhaps someone can help me, here is an extract from the structures, tables and the select statement.
Database
- public class MovieDb
- {
- public string MovieGuid {get; set;}
- public string Title {get; set;}
- public string Plot {get; set;}
- public int Time {get; set;}
- public string Langu {get; set;}
- public int FSK {get; set;}
- ...
- }
- public class ActorDb
- {
- public string ActorGuid {get; set;}
- public string DisplayName {get; set;
- public string Firstname {get; set;
- public string Lastname {get; set;
- ...
- }
- public class ActorsInMovieDb
- {
- public string MovieGuid {get; set;}
- public string ActorGuid {get; set;}
- public string Role {get; set;}
- }
- public class ActorsInMovieDatabaseView
- {
- public string MovieGuid {get; set;}
- public string ActorGuid {get; set;}
- public string DisplayName {get; set;}
- public string Role {get; set;}
- }
View Classes
- public class ActorItem
- {
- public string MovieGuid {get; set;}
- public string ActorGuid {get; set;}
- public string DisplayName {get; set;}
- public string Role {get; set;}
- }
- public class MovieItem
- {
- public string MovieGuid {get; set;}
- public string Title {get; set;}
- public string Plot {get; set;}
- public int Time {get; set;}
- public string Langu {get; set;}
- public int FSK {get; set;}
- ...
- public List
Actors { get; set;} - }
Select
- foreach (MovieMaster record in database.MovieDb)
- {
- movieItem = new MediaItem();
- mediaItem = MappingMediaItem(record);
- // --- Now, select the actors
- movieItem.Actors = database.ActorsInMovieDatabaseView.AsNoTracking().Where(x => x.MovieGuid == record.MovieGuid).ToList();
- // Select(a => new
- // {
- // DisplayName = a.DisplayName,
- // Role = a.Role
- // }
- //).ToList();
- }
Priyanka K SPosted Mar 13, 2021, 5:15 PM
Piyush PansuriyaPosted Jan 18, 2021, 7:04 AM