Forum Xamarin Xamarin.Forms

Need advice on my project

k1112k1112 Member

Hi, I am working on my project that will involve an app sending/receiving information from my database on the web, but I have no idea how to make it work. After some research it appears that I can use a Web API and a SQL server, but I still don't know the path that I have to take to achieve this.

Can someone please tell me how to:

  • Code an API
  • Connect the app with the API
  • Connect the API to the SQL server
  • Send and receive data from the app

Thank you so much for your help!

Answers

  • igorkr_10igorkr_10 Member ✭✭✭✭

    How to create api
    How to Entity Framework Core (Sqlite in example presented but you can select SQL Server)
    How to use api with EF Core (same as below but with EF Core)
    How to connect to api from client application and this
    Don't forget for Xamarin Forms fundamentals (MVVM, DependencyService, Shell). Xamarin University is useful to improve your skills.

    You can create all-in-one project with api and mobile application inside. For this open Visual Studio, select Mobile App (Xamarin.Forms) template and click Create. In next window select template for mobile application and enable Include ASP.NET Core Web Api project.

    The solution with several projects will be created. First, App1 is portable project for mobile application. Most of your client code will be here.
    App1.Android, App1.iOS, App1.UWP (UWP is not enabled for Shell template) are platform project and using for getting platform specific thing only (f. e. for DependencyService, renderers effects, etc).
    App1.Web is your web api application. Here you will operate with database and other web things.
    To operate with database use EF core (this is an ORM). Install Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.SqlServer from NuGet to App1.Web project.
    There are a lof of tutorials in web
    Good luck!

  • k1112k1112 Member

    @igorkr_10
    Thank, I've looked into EF Core and it seems very helpful, but how should it be used?
    Is it to be used between the app and the Api?
    And is it before or after serialisation or deserialisation?

    I don't see the sites mentioning these.

  • igorkr_10igorkr_10 Member ✭✭✭✭
    edited August 1
    > @k1112 said:
    > @igorkr_10
    > Thank, I've looked into EF Core and it seems very helpful, but how should it be used?
    > Is it to be used between the app and the Api?
    > And is it before or after serialisation or deserialisation?
    >
    > I don't see the sites mentioning these.

    EF Core using on backend side to operate with database (get data from db, save data to db, edit, delete, etc) in your api project (web application which is present as App1.Web). Client side (frontend, mobile application) makes a request to api and knows nothing about your database.
    See scheme below
Sign In or Register to comment.