@using System.Collections
@using RadzenBlazorDemos.Data
@using RadzenBlazorDemos.Models.Northwind
@using Microsoft.EntityFrameworkCore
@using System.ComponentModel.DataAnnotations

<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-sm-12">
    <RadzenLabel Text="Select Value" Component="DropDownCustomObjects" />
    <RadzenDropDown Data=@data TValue="MyObject" @bind-Value=@singleValue
                    AllowClear="true" AllowFiltering="true" Style="width: 100%; max-width: 400px;" Name="DropDownCustomObjects">
    </RadzenDropDown>
</RadzenStack>

@code {

    class MyObject
    { 
        public int Id { get; set; }
        public string Name { get; set; }

        public override bool Equals(object o)
        {
            var other = o as MyObject;

            return other?.Id == Id;
        }

        public override string ToString()
        {
            return $"Id: {Id}, Name: {Name}";
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }

    MyObject singleValue = new MyObject() { Id = 5, Name = "Name5" };
    IEnumerable<MyObject> data = Enumerable.Range(0, 100).Select(i => new MyObject() { Id = i, Name = $"Name{i}" });
}
