Storing your data in Graffiti the easy way

Posted on Tuesday, March 25, 2008

I've been asked by a few people the easiest way to store your data inside Graffiti. Most people start the question with "How do I add tables to the database ....". You could do that, but it would be complicated and annoying to deploy to other users. Simply use the ObjectManager and all your code will move to any Graffiti installation with ease.

Here it is, in less than 2 minutes....

add a reference to Graffiti.Core, make an object... mark it serializable

[Serializable]
public class MyObject
{
   private string _name;
   private string _description;

   public string Name
   {
       get { return _name; }
       set { _name = value; }
   }

   public string Description
   {
       get { return _description; }
       set { _description = value; }
   }
}

instantiate and call Save..

MyObject obj = new MyObject();

ObjectManager.Save(obj, "MyObjectSettings");

retrieve it later..

ObjectManager.Get<MyObject>("MyObjectSettings");

That's it!

Jayme

Comments

There are no comments.

Leave a Comment


Search this site

Last 3 Tweets

  • The lead singer in one republic looks like @stevenharman
  • after this many years, you would think installing a ssl cert would be easier. what a joke.
  • @devhammer well said :)