/// <summary>
        /// Event Handler for EntityAdded event fired by the EntityRegistry. A new entity will be persisted to the database,
        /// unless the entity to be added was just queried from the database (e.g. upon initialization)
        /// </summary>
        /// <param name="sender">Sender of the event (the EntityRegistry)</param>
        /// <param name="e">Event arguments</param>
        internal void OnEntityAdded(Object sender, EntityEventArgs e)
        {
            Entity addedEntity = e.Entity;

            // Only persist entities if they are not added during intialization on Startup
            if (!EntitiesToInitialize.Contains(addedEntity.Guid))
            {
                AddEntityToPersisted(addedEntity);
            }
            else
            {
                EntitiesToInitialize.Remove(addedEntity.Guid);
            }
            addedEntity.ChangedAttribute += new EventHandler <ChangedAttributeEventArgs>(OnAttributeChanged);
            addedEntity.CreatedComponent += new EventHandler <ComponentEventArgs>(HandleComponentCreated);
        }
        /// <summary>
        /// Retrieves the entities from database.
        /// </summary>
        internal void RetrieveEntitiesFromDatabase()
        {
            IList <Entity> entitiesInDatabase = new List <Entity> ();

            using (ISession session = SessionFactory.OpenSession())
            {
                entitiesInDatabase = session.CreateQuery("from " + typeof(Entity)).List <Entity>();
                foreach (Entity e in entitiesInDatabase)
                {
                    //if (e.Parent == null)
                    {
                        EntitiesToInitialize.Add(e.Guid);
                        World.Instance.Add(e);
                    }
                }
            }
        }