Skip to content

Instantly share code, notes, and snippets.

@rofr
Created September 17, 2014 03:12
Show Gist options
  • Select an option

  • Save rofr/eeac5c0390101b97783a to your computer and use it in GitHub Desktop.

Select an option

Save rofr/eeac5c0390101b97783a to your computer and use it in GitHub Desktop.
Naive OrigoDB document database model
[Serializable]
public class DocumentModel : Model
{
private readonly Dictionary<object,object> _documents;
public DocumentModel()
{
_documents = new Dictionary<object, object>();
}
public T Get<T>(object key)
{
return (T) Get(key);
}
public object Get(object key)
{
return _documents.ContainsKey(key) ? _documents[key] : null;
}
public void Put(object key, object document)
{
_documents[key] = document;
}
public bool Remove(object key)
{
return _documents.Remove(key);
}
public T ExecuteQuery<T>(Func<Dictionary<object, object>, T> query)
{
return query.Invoke(_documents);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment