| File: Hotel.cs | Web Access |
| Project: src\playground\AzureSearchEndToEnd\AzureSearch.ApiService\AzureSearch.ApiService.csproj (AzureSearch.ApiService) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Text.Json.Serialization; using Azure.Search.Documents.Indexes; using Azure.Search.Documents.Indexes.Models; namespace AzureSearch.ApiService; public class Hotel { [SimpleField(IsKey = true, IsFilterable = true)] public string? HotelId { get; set; } [SearchableField(IsSortable = true)] public string? HotelName { get; set; } [SearchableField(AnalyzerName = LexicalAnalyzerName.Values.EnLucene)] public string? Description { get; set; } [SearchableField(AnalyzerName = LexicalAnalyzerName.Values.FrLucene)] [JsonPropertyName("Description_fr")] public string? DescriptionFr { get; set; } [SearchableField(IsFilterable = true, IsSortable = true, IsFacetable = true)] public string? Category { get; set; } [SearchableField(IsFilterable = true, IsFacetable = true)] public string[]? Tags { get; set; } [SimpleField(IsFilterable = true, IsSortable = true, IsFacetable = true)] public bool? ParkingIncluded { get; set; } // SmokingAllowed reflects whether any room in the hotel allows smoking. // The JsonIgnore attribute indicates that a field should not be created // in the index for this property and it will only be used by code in the client. [JsonIgnore] public bool? SmokingAllowed => (Rooms != null) ? Array.Exists(Rooms, element => element.SmokingAllowed == true) : (bool?)null; [SimpleField(IsFilterable = true, IsSortable = true, IsFacetable = true)] public DateTimeOffset? LastRenovationDate { get; set; } [SimpleField(IsFilterable = true, IsSortable = true, IsFacetable = true)] public double? Rating { get; set; } [SearchableField] public Address? Address { get; set; } public Room[]? Rooms { get; set; } public override string ToString() => $"Id: {HotelId}, Name: {HotelName}"; }