public static IQueryable <TEntry> WhereHasArtistParticipationStatus <TEntry, TArtistLink>(
            ArtistParticipationQueryParams <TEntry, TArtistLink> queryParams)
            where TEntry : IEntryWithArtists <TArtistLink> where TArtistLink : IArtistWithSupport
        {
            var query           = queryParams.Query;
            var childVoicebanks = queryParams.ChildVoicebanks;

            if (!queryParams.ArtistIds.HasAny)
            {
                return(query);
            }

            if (queryParams.ArtistIds.HasMultiple)
            {
                return(WhereHasArtists <TEntry, TArtistLink>(query, queryParams.ArtistIds, childVoicebanks));
            }

            var participation            = queryParams.Participation;
            var artistGetter             = queryParams.ArtistGetter;
            var artistId                 = queryParams.ArtistIds.Primary;
            var mainEntriesExpression    = queryParams.MainEntriesExpression;
            var collaborationsExpression = queryParams.CollaborationsExpression;

            if (participation == ArtistAlbumParticipationStatus.Everything)
            {
                return(WhereHasArtist <TEntry, TArtistLink>(query, artistId, childVoicebanks));
            }

            var artist             = artistGetter(artistId);
            var musicProducerTypes = new[] { ArtistType.Producer, ArtistType.Circle, ArtistType.OtherGroup };

            if (musicProducerTypes.Contains(artist.ArtistType))
            {
                switch (participation)
                {
                case ArtistAlbumParticipationStatus.OnlyMainAlbums:
                    return(query.Where(mainEntriesExpression));

                case ArtistAlbumParticipationStatus.OnlyCollaborations:
                    return(query.Where(collaborationsExpression));

                default:
                    return(query);
                }
            }
            else
            {
                switch (participation)
                {
                case ArtistAlbumParticipationStatus.OnlyMainAlbums:
                    return(query.Where(al => al.AllArtists.Any(a => (a.Artist.Id == artistId || (childVoicebanks && a.Artist.BaseVoicebank.Id == artistId)) && !a.IsSupport)));

                case ArtistAlbumParticipationStatus.OnlyCollaborations:
                    return(query.Where(al => al.AllArtists.Any(a => (a.Artist.Id == artistId || (childVoicebanks && a.Artist.BaseVoicebank.Id == artistId)) && a.IsSupport)));

                default:
                    return(query);
                }
            }
        }
Ejemplo n.º 2
0
        public static IQueryable <Song> WhereHasArtistParticipationStatus(this IQueryable <Song> query,
                                                                          ArtistParticipationQueryParams queryParams,
                                                                          IEntityLoader <Artist> artistGetter)
        {
            var various       = Model.Helpers.ArtistHelper.VariousArtists;
            var producerRoles = ArtistRoles.Composer | ArtistRoles.Arranger;
            var artistId      = queryParams.ArtistIds.Primary;

            return(EntryWithArtistsQueryableExtender.WhereHasArtistParticipationStatus(new ArtistParticipationQueryParams <Song, ArtistForSong>(query, queryParams, artistGetter,
                                                                                                                                                al => al.AllArtists.Any(a => a.Artist.Id == artistId && !a.IsSupport && ((a.Roles == ArtistRoles.Default) || ((a.Roles & producerRoles) != ArtistRoles.Default)) && a.Song.ArtistString.Default != various),
                                                                                                                                                al => al.AllArtists.Any(a => a.Artist.Id == artistId && (a.IsSupport || ((a.Roles != ArtistRoles.Default) && ((a.Roles & producerRoles) == ArtistRoles.Default)) || a.Song.ArtistString.Default == various))
                                                                                                                                                )));
        }