Windows 7 Phone Database - RapidRepository

Hi All,

Just a quick note to let people know about a project I’ve started that hopefully will be really helpful for people about to start developing for the Windows 7 Phone.

The project called Rapid Repository is a essentially a document database that sites on top of the windows 7 phone isolated storage.

The repository is really simple to use (There is no setup, the following code example shows pretty much all you have to do to persist data).

You create a repository derived from the RapidRepository<> and you can do the usual Add, Update, Delete, GetAll and Query.

Once you have added, updated or deleted your entities, you simple call RapidContext.CurrentContext.SaveChanges() and all of your changes are persisted.

For example:

Save Changes Example
  1. ICustomerRepository repository = new CustomerRepository();
  2.  
  3. Customer customer = new Customer();
  4. customer.Name = "Sean";
  5. customer.Address = new Address() { PostCode = "SW1 XXX" };
  6. customer.FavouriteUrls.Add("http://www.codeplex.com");
  7.  
  8. repository.Add(customer);
  9.  
  10. RapidContext.CurrentContext.SaveChanges();

You can also query the database using linq for example:

Linq Query Example
  1. var customers = repository.Query().where(x => x.Address.PostCode.Contains("SW1")).ToList();

Note: You will need to implement IRapidEntity on your root entity – this literally enforces a Guid id on the root entity.

I have a basic road map to add transactional support, implement a proper query solution including indexes/views etc.

The full source code and a test mobile app can be found at codeplex via the following: http://rapidrepository.codeplex.com/

Anyway, I would love to hear any thoughts and ideas for the project and I hope you find it useful.

Kind Regards,

Sean McAlinden.

No Comments