Having issues getting data to a listbox

I have created a new project in studio and then connected it to my sql server using the option generate pages for CRUD operations.

the pages.cs is
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Test10311.Models.Club_001
{
[Table("Rooms", Schema = "dbo")]
public partial class Room
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int RoomID { get; set; }

    public string RoomName { get; set; }

    public bool? RoomInUse { get; set; }

    public decimal? RoomHourlyRate { get; set; }

    public bool? RoomAvailable { get; set; }

    public bool? RoomSingle { get; set; }

    public int? RoomAutoCheckOut { get; set; }

}
public partial class RoomListClass
{

    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int RoomID { get; set; }

    public string RoomName { get; set; }


}

}

I added the RoomListClass

I want to use the code below

I get that my code should look like below but I don;'t understand how to get the data.

@code {
string ValueRoom;
IEnumerable RoomList;

protected override async Task OnInitializedAsync()
{
    await base.OnInitializedAsync();

    RoomList = ???????????????????????????; // This is the part I'm missing
}

}

so what to I do to get Roomlist to a list of RoomListClass using the CRUD that was built for the table Rooms?

Thanks Kirk

Not sure I understand how this is related to Radzen IDE for Blazor server, can you clarify? Using Radzen IDE you can bind your ListBox in the designer and the code will be generated when you run the app.

@KirkGroome Are you using Radzen or Radzen Blazor Studio?

If you use Radzen you can populate the ListBox from the property grid - pick "new ..." as an option for the Data property.

If you use Radzen Blazor Studio you can use the Configuration wizard of the listbox and pick the name of the method that has been generated.

Finally if you want to do that from code you have to:

  1. Inject the service that has been generated for your data source.
  2. Use its GetRoomListClasses() method.
@code {
     [Inject]
     private RoomListService Service { get; set; } // inject the service to your component
     IEnumerable<RoomListClass> RoomList;

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
    
        RoomList = await Service.GetRoomListClasses();
    }
}

Similar code would be automatically generated if you use the other options.

Thank you very much that got it resolved for me!