Use MongoDB With Your Xamarin Apps

MatthewSoucoupMatthewSoucoup USMember, Insider, University, Developer Group Leader mod

We just published our blog on Using MongoDB with Your Xamarin Apps. Please feel free to discuss the contents of this blog here. If you have any questions about open source, the Xamarin.Android project, or just want to stop by and say you enjoyed the content, this is the place to do that!

Posts

  • TonySimoesTonySimoes USMember

    Thank you MatthewSoucoup :)

    I really liked your article, very well explained, enough to start with MongoDB.
    I tested your code with UWP and Azure Cosmos Emulator and it works.
    I think it can be an alternative in the development phase.

  • MatthewSoucoupMatthewSoucoup USMember, Insider, University, Developer Group Leader mod

    Thank you @TonySimoes! I'll update the article to mention the Azure Cosmos DB Emulator!

  • c12345c12345 Member

    hello ... do you have any idea if you can use mongo db locally in android, using xamarin

  • MatthewSoucoupMatthewSoucoup USMember, Insider, University, Developer Group Leader mod

    Right now it's online only with Cosmos - no offline access.

  • ClubberLangClubberLang BEMember ✭✭

    Hi Matthew,

    It is not really MongoDB, it is ComosDB with a compatible API, right ?

    Because there is also MongoDB-cloud-atlas : https://www.mongodb.com/cloud

    But, does it keep the same pricing model thant CosmosDB ? Because the current CosmosDB pricing model
    is not dynamic (based on number of collection and RU {Reserve Unit}), so even if you don't use it at all for sometime,
    you pay (a lot) ! When you see all the other cloud database, the pricing is based on real ressources use :-(

    For now, cosmos for to :

    • it force to care more about the price than the design (do everything in one collection !)
    • it is not dynamic based on resources usage (more users / less users at some times)

    This is a STOP condition for us :-(

    It is a shame because CosmosDB do the job otherwise, and it is well integrated with the other Azure services !

  • MatthewSoucoupMatthewSoucoup USMember, Insider, University, Developer Group Leader mod

    Hi @ClubberLang - can you email me at Matt.soucoup @ microsoft . com? I'd like to ask you some questions about how you'd like to use the mongo api for cosmos (like, how many collections your current project could use ... stuff like that). I'll use that info to pass along to the Cosmos team - thanks!

  • Eisbein123Eisbein123 Member ✭✭

    Hi @MattSoucoup , thanks for the great article on using Xamarin forms with mongo. I Have a bit of a performance issue with this block of code

    public async static Task<List<ToDoItem>> GetAllItems()
            {
                var allItems = await ToDoItemsCollection
                    .Find(new BsonDocument())
                    .ToListAsync();
    
                return allItems;
            }
    

    I Have updated the connection part of your app to point my mongo db and ToDoItemsCollection populates very quickly from there but as soon as i convert this list with the statement above i get some very bad performance. Like 4-5 seconds and i only load about 9 documents.

    Would you know anything i could do to improve performance?

    Best Regards
    Wil

  • MatthewSoucoupMatthewSoucoup USMember, Insider, University, Developer Group Leader mod

    Hi @Eisbein123 - yeah, something's not right there. You shouldn't be experiencing any performance issues at all. Out of curiosity, what happens if you do something like:

    var allItems = await ToDoItemsCollection
                .AsQueryable()
                .Where(t => t.Complete == true)
                .ToListAsync();
    
Sign In or Register to comment.