Générique Référentiel pour SQLite-Net en Xamarin Projet

Je me demande si il y a une façon d'écrire un générique référentiel pour mon Xamarin projet de rapport à l'écriture d'un Référentiel pour chaque entité de mon objet. Le Xamarin Tasky Pro exemple, un Référentiel pour l'entité Tâche parce que c'est la seule entité.

Dans mon projet, j'ai plus d'une Entité, donc ma question est comment puis-je faire
le Client suivant Référentiel de devenir générique, de sorte que le ProductManager, EmployeeManager, etc, peuvent l'utiliser. Si vous connaissez un exemple ou un billet de blog, merci de m'indiquer la bonne direction

namespace App.DataLayer
{
    public class CustomerRepository
    {
        private ProntoDatabase _db = null;
        protected static string DbLocation;
        protected static CustomerRepository Me;

        static CustomerRepository()
        {
            Me = new CustomerRepository();
        }

        protected CustomerRepository()
        {
            //set the db location;
            DbLocation = DatabaseFilePath;

            //instantiate the database
            _db = new ProntoDatabase(DbLocation);
        }


        public static string DatabaseFilePath
        {
            get
            {
                const string sqliteFilename = "CustomerDB.db3";
                var libraryPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                var path = Path.Combine(libraryPath, sqliteFilename);
                return path;
            }
        }


        //CRUD (Create, Read, Update and Delete) methods

        public static Customer GetCustomer(int id)
        {
            return Me._db.GetItem<Customer>(id);
        }

        public static IEnumerable<Customer> GetCustomers()
        {
            return Me._db.GetItems<Customer>();
        }

        public static int SaveCustomer(Customer item)
        {
            return Me._db.SaveItem(item);
        }

        public static int DeleteCustomer(int id)
        {
            return Me._db.DeleteItem<Customer>(id);
        }
    }
Vous devez maintenant passer à la mise en œuvre de ISQlitePlatform dans le SQLiteConnectionWithLock et SQLiteConnection constructeurs. La plate-forme correcte mise en œuvre est automatiquement ajouté au projet.

OriginalL'auteur Val Okafor | 2015-03-14