Пример #1
0
 public static Document GetDocument(this SongDocument songDocument)
 {
     return(new Document
     {
         new TextField(nameof(songDocument.Album), songDocument.Album.ToStringSafe(), Field.Store.YES),
         // StringField indexes but doesn't tokenize
         new StringField(nameof(songDocument.SongPk), songDocument.SongPk.ToStringSafe(), Field.Store.YES),
         new TextField(nameof(songDocument.Genres), songDocument.Genres.ToStringSafe(), Field.Store.YES),
         new TextField(nameof(songDocument.SingerAKANames), songDocument.SingerAKANames.ToStringSafe(), Field.Store.YES),
         new TextField(nameof(songDocument.SingerNames), songDocument.SingerNames.ToStringSafe(), Field.Store.YES),
         new TextField(nameof(songDocument.SongAKATitles), songDocument.SongAKATitles.ToStringSafe(), Field.Store.YES),
         new TextField(nameof(songDocument.SongTitle), songDocument.SongTitle.ToStringSafe(), Field.Store.YES),
         new Int32Field(nameof(songDocument.SongSeconds), songDocument.SongSeconds, Field.Store.YES),
         new StoredField(nameof(songDocument.AlbumDescription), songDocument.AlbumDescription.ToStringSafe()),
         new StoredField(nameof(songDocument.SingerDescription), songDocument.SingerDescription.ToStringSafe()),
         new StoredField(nameof(songDocument.ReleaseDate), songDocument.ReleaseDate.ToStringSafe()),
         new StoredField(nameof(songDocument.Picture), songDocument.Picture ?? Array.Empty <byte>()),
     });
 }
Пример #2
0
        public static SongDocument GetSongDocument(this Song song)
        {
            var docuemnt = new SongDocument
            {
                Album             = song.Album?.Title,
                Genres            = string.Join(CommonConstants.Separater, song.GenreSongs?.Select(u => u.Genre?.Title) ?? Enumerable.Empty <string>()),
                SingerAKANames    = string.Join(CommonConstants.Separater, song.SingerSongs?.Select(u => u.Singer?.AKANames) ?? Enumerable.Empty <string>()),
                SingerNames       = string.Join(CommonConstants.Separater, song.SingerSongs?.Select(u => u.Singer?.Name) ?? Enumerable.Empty <string>()),
                SongAKATitles     = song.AKATitles.ToStringSafe(),
                SongTitle         = song.Title.ToStringSafe(),
                SongPk            = song.Pk.ToString(),
                SongSeconds       = song.Seconds,
                AlbumDescription  = song.Album?.Description,
                Picture           = song.Picture,
                ReleaseDate       = song.Album.ReleaseDate?.ToString(CommonConstants.DateTimeFormat),
                SingerDescription = string.Join(CommonConstants.Separater, song.SingerSongs?.Select(u => u.Singer?.Description) ?? Enumerable.Empty <string>()),
            };

            return(docuemnt);
        }