title: Generic Repository for SQLite-Net in Xamarin Project
body: <p>I am wondering if there is a way to write a generic repository for my Xamarin project versus writing a different Repository for each entity in my object. The Xamarin <a href="https://github.com/xamarin/mobile-samples/blob/master/TaskyPro/Tasky.Core/DataAccessLayer/TaskRepository.cs">Tasky Pro</a> example have one Repository for the Task entity because that is the only entity it has.</p>
  
  <p>In my own project I have more than one Entity, so my question is how can I make 
  the following Customer Repository to become generic so that the ProductManager, EmployeeManager, etc can use it. If you know of an example or a blog post please point me to the right direction</p>
  
  <pre><code>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&lt;Customer&gt;(id);
          }
  
          public static IEnumerable&lt;Customer&gt; GetCustomers()
          {
              return Me._db.GetItems&lt;Customer&gt;();
          }
  
          public static int SaveCustomer(Customer item)
          {
              return Me._db.SaveItem(item);
          }
  
          public static int DeleteCustomer(int id)
          {
              return Me._db.DeleteItem&lt;Customer&gt;(id);
          }
      }
  </code></pre>