Very new to MAUI but how does on connect to a DB, say Ms SQL, and then assign to the datagrid?
1 Answer, 1 is accepted
0
Accepted
Lance | Senior Manager Technical Support
Telerik team
answered on 24 May 2022, 05:16 PM
Hello Deasun,
With any XAML/C# framework like MAUI, WPF, etc, you would have an intermediary layer that connects to the database and gives you .NET object for those database items. Once you have that data, you can connect it to the Telerik controls.
Telerik UI for MAUI doesn't provide this database layer, you can get it with something like Microsoft's EntityFramework Core (aka EF Core).
Quick Conceptual Example
For example, let's say your database has a table of cars, with columns for model, make and year. EF Core will create C# classes for that item:
publicclassCar
{
publicstring Make { get; set; }
publicstring Model { get; set; }
publicint Year { get; set; }
}
Then EF Core communicates with the database to pull in the records, which gives you with a List<Car>. Once you have that List<Car>, you can then use the Telerik UI for MAUI components.
For example, with the DataGrid:
// Step 1. Get the data from your database
List<Car> myCars = MyCarsDataBaseService.GetCars();
// step 2. Now you can use it
DataGrid.ItemsSource = myCars;
Resources
We don't have any documentation on how to EF Core as this is Microsoft's technology. You should be able to find plenty of online resources on how to add an use it in a .NET 6 application: search for "How to use EntityFramework in a .NET6 project"
Regards,
Lance | Manager Technical Support
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.