I use ASP.NET Core and EF Core.
I have two tables FileType and UniversityFile.
UniversityFile saves number of each file extensions in some universities. I want to join these two tables and get a list to send to a method which creates an Excel report.
This is an example of the FileType and UniversityFile tables:
{
List<FileType> FileTypes= new List<FileType>()
{
new FileType() { Id = 1, Extention= "Zip" },
new FileType() { Id = 2, Extention= "MP3" },
new FileType() { Id = 3, Extention= "Ogg" },
};
List<UniversityFile> UniversityFiles= new List<UniversityFile>()
{
new UniversityFile() { UniversityId = 1, FileTypeId = 1, Count = 5 },
new UniversityFile() { UniversityId = 1, FileTypeId = 2, Count = 10 },
new UniversityFile() { UniversityId = 1, FileTypeId = 3, Count = 5 },
new UniversityFile() { UniversityId = 2, FileTypeId = 1, Count = 10 },
new UniversityFile() { UniversityId = 2, FileTypeId = 2, Count = 10 },
new UniversityFile() { UniversityId = 2, FileTypeId = 3, Count = 10 }
};
}
and here is the list I need to send to my method
var data = new List<>()
{
new { UniversityId = 1, Zip = 5, MP3 = 10, Ogg = 5 },
new { UniversityId = 2, Zip = 10, MP3 = 10, Ogg = 10 },
};
I tried Linq Join but I can't find the right way to get the list