Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Sharing services between platforms (Web/mobile)

$
0
0

We are creating an ASP.Net Core SPA app that will have Xamarin.Forms based mobile apps to go along with it. The mobile apps will mirror the majority of the functionality in the SPA app, so we're wanting to try and write our code to be as re-usable as possible. We've broken our business logic out into a series of PCLs that represent our Domain objects, our Services out into a series of PCLs and our data access and security into another series of PCLs.

The issue we have right now though is that our service PCLs that are used for talking to the database, use IDbConnection to query the Sql Server Database on the SPA. It looks like Xamarin.Forms does not have this interface, and instead we have to use the SQLiteConnection object that ships with the SQLite database packages. With that being the case, it would mean we'd have to write new implementations for every one of our services in the service layer. This would drastically reduce the percentage of code we can share which would be really unfortunate. It also seems that SQLite.net doesn't allow for async operations within a transaction.

With these limitations, I'm wondering what alternatives there might be. I really want to use IDbConnection across all platforms. If we moved away from Xamarin.Forms and just used the Xamarin native project types, would we be able to use IDbConnection? If so, what Database packages are there that implement it we could use? Since the SQLite supported by Xamarin.Forms doesn't implement that interface, we'd have to use another database nuget package. Are there any that Xamarin native projects could consume?

Thanks


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>