Basic DB ?

1 Answer 117 Views
DataGrid
Deasun
Top achievements
Rank 3
Bronze
Bronze
Bronze
Deasun asked on 24 May 2022, 04:37 PM

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

Sort by
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:

public class Car
{
    public string Make { get; set; }
    public string Model { get; set; }
    public int 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"

Once you do have that part of your application set up, you can then use our DataGrid documentation on how to use that data => .NET MAUI DataGrid Documentation | Overview | Telerik UI for .NET MAUI.

I hope this helps explain things!

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/.

Tags
DataGrid
Asked by
Deasun
Top achievements
Rank 3
Bronze
Bronze
Bronze
Answers by
Lance | Senior Manager Technical Support
Telerik team
Share this question
or