Storing cosmos / container based data in a local database.

Bubba Jones 206 Reputation points
2022-10-23T10:04:15.063+00:00

I am developing a MAUI (mobile) app and would like to store cosmos based container data to a local db. I was previously advised on these forums to use SQLIte's json support. However despite my best efforts in scouring the internet, I have not found a single sample of C# code storing json data locally in an actual databse. I only found samples that stored json data in text files.

What I am after is a link to some documentation / source code in C# that stores json / container data in an actual local database (not a file) using sqlite or whatever local db tool that allows me to do this. Help would be appreciated as I couldn't find anything in my searches that allowed me to do this.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,267 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
11,609 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Oury Ba-MSFT 14,061 Reputation points Microsoft Employee
    2022-10-25T17:02:28.33+00:00

    Hi @Bubba Jones Thank you for posting your question on Microsoft Q&A and for using Azure services.

    As per my understanding you are trying to store cosmos db based container into a local db and want to know if SQLite will help achieve that.

    You could serialize your json as string and save it as straight up text. Then if you want to query off json objects, that's where that json functions come into play.

    SQLite has a json_type column that you can make use of. JSON functions and Operators

    Regards,
    Oury