UWP Desktop and database

Asked

Viewed 184 times

0

I’m developing an application for leasing-related business management purposes. The trivial CRUD, reports, controls etc, commonly developed in windows Forms. However, I am making a UWP application.

The dilemma begins with the fact that UWP applications cannot access the ADO.NET classes, so the only way (I knew) UWP apps work with databases is via Webservice. The problem is that I am having some difficulty trying to fit the whole rule related to data persistence within the Webservice. I searched for information on what would be the best way to do this and found suggestions to create a service for each entity to be persisted in the database, but I do not find a solution very practical and "elegant".

I also thought about creating generic CRUD methods that could persist any type of entity, that is, a single insert(AnyType anyData) to insert any set of data in its appropriate table. But I could not advance the reasoning, because each entity is very particular. Some have more properties than others, others have collections like properties (List, Dictionary), which will be persisted in separate tables (Example: LEASE and ITENS_DA_LOCATION), others do not have, some are extremely simple and some are more complex. Finally, creating a generic CRUD methods is not a simple task.

What other solution could I try in this case?

  • 1

    I can’t say if you can’t access the database, you might not be able to use ADO.NET, but it’s a specific restriction. You need to see if you need to do UWP, it may not be the most appropriate option. Even if you do *please access the database from another source, there are several other ways to do this without it being a webservice. It may be that UWP has some restrictions that I don’t know, but if this is true for me it is not good for virtually anything, until you create an app on iOS can more.

  • Almost everything you have on the Internet are complex solutions to problems that should be complex, but most problems are simple.

  • I decided to go via UWP to take advantage of the visual resources of UWP. There is WPF but UWP introduces a lot of new things and makes it easier to create certain components than in WPF would be painful to do. HamburgerMenu in the WPF is a birth, already in the UWP there is the component ready. You said there would be other ways to work with UWP and database. What would be?

  • I’ve never used UWP and I don’t know it well, but as well as being clear that it has what it takes, there are a few things out there: https://code.msdn.microsoft.com/How-to-access-data-from-5f2602ec, https://docs.microsoft.com/en-us/windows/uwp/data-access/, https://blogs.owwinds.com/buildingapps/2017/02/06using-sqlite-Databases-uwp-apps/#9u5tL2h4WuwOhpGr.97. Can access the database through a service, but does not need to be webservice, maybe by TCP/IP, has many ways

  • If it is a single-user application could choose to SQLite (local storage). Other situations at the moment do not see a solution other than something related to service. It doesn’t treat exactly as you say in the question 'um serviço para cada entidade', a service serves yes all entities. I’m also starting to learn this part of webservice dotnetcore already has a lot of material on the subject, along with efcore we can already start to create services. These are recent technologies but the trend and evolve.

  • The function of WebService would not be exactly working with data manipulation but rather receiving and responding to customer requests. The work of data manipulation would be done for example by a dll (Projeto c#). I recommend (if you don’t already know) learning about efcore (Entity framework core) https://docs.microsoft.com/en-us/ef/core/index

Show 1 more comment

1 answer

1


In this case, I recommend the study of the Entity Framework Core, which can use Sqlite databases and whose mapping is fully automatic in simpler scenarios, where each "child" table has only one "parent" table".

If it is necessary that other machines modify only a "central" database can be made use of sockets, I recommend using Restup, which will basically transform your app into a REST server, perfect for this type of case, any doubt just speak.

  • Hello! In my case the UWP application should persist the data in a database in the cloud, where other users will also persist. Briefly it will be an Azure SQL server instance where UWP applications should persist. In this case you would recommend Sockets?

  • Yes, that’s the most recommended.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.