Forum Cross Platform with Xamarin

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

ORM Selection

We have an existing enterprise java android app - the succcess of which has lead to a requirement for platform diversification and a single code base wherever possible - and Xamarin was at the top of my list of possibilities. We were spoilt in java with the availability of the superb Ormlite library and Vici Coolstorage would seemingly be the only ORM that offers similar functionality?
Just wondering if anyone had used the Vici Coolstorage codebase across android/ios/wp7 with relative success?

Posts

  • [Deleted User][Deleted User] Xamurai
    edited February 2013

    I'm also pretty interested in hearing about this. I've been using Vici CoolStorage for iOS, but haven't tried it on Android or do anything cross-platform in nature with it.

    Edit: After re-evaluating my options, I found SQLite-Net to be the one that I found easiest to work with.

  • StuartLodgeStuartLodge USBeta ✭✭✭

    I've used Vici CoolStorage on Droid and WP7 before - both worked well.

    Currently I mainly seem to be using the https://github.com/praeclarum/sqlite-net with a DI wrapper around it. Again works well :)

  • NicWiseNicWise NZMember, Insider, Beta mod

    Second vote for sqlite-net. Been working really well for ages for me. You have to be careful with threads with SQLite (dont pass connections across threads etc), but it's not hard

  • DuarteDuarte USBeta ✭✭

    I've been using OpenNETCF.ORM (http://orm.codeplex.com/) for quite some time now and I'm very pleased with it. It works on .NET Compact Framework, WP7 and Mono for Droid. Although there is no Monotouch implementation, it was very easy to make a port based on the Mono for Droid implementation.

  • AlexWhiteAlexWhite GBMember ✭✭✭

    I had a look at Vici, but settled on sqlite-net being able to view the source code was the main reason for going with sqlite-net as I sometimes need that level of access, having now done a number of modifications I am sure I would have hit brick walls with Vici.

  • BryanCostanichBryanCostanich USMember, Xamarin Team Xamurai

    Personally, I have found Vici to be, among other things, architecturally awkward and slow. I found SQLite-Net 2x or more as fast for most operations and much easier to implement. We've also added another set of Generic methods to SQLite-Net in several of our sample apps that greatly simplify the common CRUD calls. You can see an example here: https://github.com/xamarin/mobile-samples/blob/master/TaskyPro/Tasky.Core/DataLayer/TaskDatabase.cs

    that makes CRUD operations as easy as:

    public static Task GetTask(int id)
    {
        return DAL.TaskRepository.GetTask(id);
    }
    
    public static IList<Task> GetTasks ()
    {
        return new List<Task>(DAL.TaskRepository.GetTasks());
    }
    
    public static int SaveTask (Task item)
    {
        return DAL.TaskRepository.SaveTask(item);
    }
    
    public static int DeleteTask(int id)
    {
        return DAL.TaskRepository.DeleteTask(id);
    }
    

    I've used ORMLite in java and it's also very similar, though not quite as powerful (C# has better generics, among other things that make it more elegant).

  • SridharanSrinivasanSridharanSrinivasan SGMember ✭✭
    edited November 2012

    I am using modified PetaPoco MicroORM http://www.toptensoftware.com/petapoco/ for my Web App as well as in Mono for Android and Mono Touch. You can look at a example usage in GitHub (https://github.com/Srid68/Priya.InfoList) of my Reference Application in the App_Gen Folder
    (https://github.com/Srid68/Priya.InfoList/blob/master/src/Priya.InfoList/App_Gen/DataSource/DataSource.cs)

    Now I am creating an DAL Abstraction over PetaPoco and SQLite.NET so that I can use it for WinRT

    The biggest advantage for me in using PetaPoco was the support for Paging using SQL Statements.

  • KernCarboniKernCarboni NZMember

    Thanks for the responses. I will go with popular consensus for now and use the sqlite.net.
    Only required for a proof of concept prototype anyway.

  • BrewDawgBrewDawg USMember, Beta

    We have a very mature ORM (derived from EntitySpaces) that has full Xamarin support, it supports all of the platforms Mono Touch runs in. We also support SQLite of course (in addition to a ton of other db's). The ORM is database independent. We have guys running SQLite on the iPad through Mono Touch and sending their data to the Server to be saved in SQL Server. And they use the same physical objects on both side, it's truly independent.

    We'll be putting some how to video's out in the next day or so, you can create your project and all your entities reverse engineered from your database in about 10 minutes.

    It's called Tiraggo

    See http://brewdawg.github.com/Tiraggo/

    The code is very easy to write and high level:

    Employee emp = new Employee();
    emp.FirstName = "Joe";
    emp.LastName = "Smith"
    emp.Save();
    

    The DynamicQuery API is just like writing SQL and the same for all databases

    EmployeeQuery q = new EmployeeQuery();
    q.Select(q.EmployeeID, q.Age.Sum().As("TotalAge"));
    q.Where(q.EmployeeID.IsNotNull());
    q.GroupBy(q.EmployeeID);
    q.Having(q.Age.Sum() > 5);
    q.OrderBy(q.EmployeeID.Descending);
    
    EmployeeCollection coll = new EmployeeCollection();
    if (coll.Load(q))
    {
    
    }
    

    The query above will generate this SQL

    SELECT [EmployeeID] AS 'EmployeeID', SUM([Age]) AS 'TotalAge'  FROM
    [dbo].[Employee]
    WHERE[EmployeeID] IS NOT NULL
    GROUP BY [EmployeeID]
    HAVING SUM([Age]) > @Age2
    ORDER BY [EmployeeID] DESC
    

    of course you can do joins and far more complex queries than shown above.

    The Tiraggo Business Objects will serialize full object graphs back and forth (JSON or XML) and can work with or without stored procedures.

    It's all free ...

  • BrewDawgBrewDawg USMember, Beta

    This is basically what the Tiraggo architecture looks like:

    See:

    C# - http://brewdawg.github.com/Tiraggo/

    JavaScript - http://brewdawg.github.com/Tiraggo.js/

  • MihaMarkicMihaMarkic SI ✭✭✭✭

    Hi Brew,

    Interesting concept although I don't like very much the cloud generation template feature. Would be possible to get template sources as well or are they already at github?

Sign In or Register to comment.