Я пытаюсь создать список песен, которые существуют во всех ящиках.
У ящиков есть собственная таблица: TableBoxNames (BoxID, Filtered, name и т. Д.) У песен в ящиках есть собственная таблица: TableBoxSongs (SongID, BoxID и т. Д.) У песен есть собственная таблица: TableSongs (SongID, исполнитель, название и т. Д.)
Идея состоит в том, чтобы составить список всех песен, которые существуют во всех отфильтрованных блоках.
Ничто здесь не работает.
Спасибо заранее за помощь мне.Шахар,
вот мой код:
private void LibraryAddBoxFilters()
{
//create list of songs that match checked boxes
using (var db = new TalLocalDbEntities())
{
//get filtered box with min number of tracks
var id = db.TableBoxNames.Where(a => a.Filter == true).Min(a => a.Tracks);
//get all songs from filtered box with min number of tracks
var myResult = from b in db.TableBoxNames //get boxes
join n in db.TableBoxSongs on b.ID equals n.BoxID //connect box id to boxid
where b.ID == id //select filtered box
select n //retrieve TableBoxSong
;
//for each Filter box selected
foreach (var p in db.TableBoxNames.Where(a => a.Filter == true))
{
if (p.ID != id)//if not first table
//filter boxsongs
myResult.Intersect(from b in db.TableBoxNames //get boxes
where b.ID == p.ID //select filtered box
join n in db.TableBoxSongs on b.ID equals n.BoxID //connect box id to boxid
select n); //retrieve TableBoxSong
}
//convert boxsongs to songs and send to library
prog.CtrlMusicLibrary.matchfilter_Songs = (from m in myResult
join s in db.TableSongs on m.SongID equals s.ID
select s).Distinct().ToList();
}
}