title: Google Calendar sync with database
body: <p>I am using <strong><code>google calendar api v2</code></strong>, and currently looking for a way to synchronize a google calendar with a local application/database (using <strong><code>C#</code></strong>, data being stored in a <strong><code>SQL Compact</code></strong> database). I am doing this because I am aiming to create an application that still functions once an internet connection has been lost (therefore data needs to be stored locally). Querying and updating events on the application level work fine, however I am running into several issues:</p>
  
  <p><strong>1) Querying if an event (stored in DB) still exists in google calendars:</strong></p>
  
  <p>My current system is more-or-less working. For each calendar event stored in the database, I run a query against google calendar for that particular 'key' (approx 26 character string) - if nothing is returned, then the event must no longer exist. But this causes two problems; the first being that it is expensive to do separate queries for each calendar event, and isn't really very usable for larger calendars. The second problem is that after a while the calendar starts to always return nothing, making the application think that <em>all</em> the events have been deleted - obviously not ideal as the last thing I want to do is delete all the local events. My best guess is that google starts to return null perhaps because I am sending too many requests - although I can't be sure on that.</p>
  
  <p>Edit: I have solved this problem using <code>entry.Status</code>. If an event is cancelled, it returns the url:
  <code>http://schemas.google.com/g/2005#event.canceled</code></p>
  
  <p>Using this you can detect which events have been deleted on the google's side. </p>
  
  <p><strong>2) Querying events modified-date on google calendars:</strong></p>
  
  <p>Currently if I want to query events that have been modified after a certain date, I add the following line to my query:</p>
  
  <p><code>query.ExtraParameters="orderby=startime&amp;sortorder=ascending&amp;updated-min=" + date;</code></p>
  
  <p>This returns all calendar events modified since the supplied date, however, to my knowledge, there doesn't seem to be any way of retrieving the actual <em>date an event was modified</em>. At least, not in v2. Is this correct? If so, how else could I achieve this?</p>
  
  <p>The problems I'm having are either because the functionality of the google calendar api is limited, or there isnt enough information in the documentation.</p>
  
  <p>If anyone could offer any insight on these issues then it would be much appreciated.</p>