Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

actions

blackshadev edited this page Jun 1, 2015 · 3 revisions

Actions

Creating actions for HybreDb is currently the only way to get information out of the database besides the already available actions. Luckily this is fairly simplistic to do.

Every action has the following prerequisites:

  • It resides within the HybreDb.Actions namespace
  • It extends the IHybreAction interface and implements its members (HybreResult Execute(Database db))
    • The function Execute returns an instance of HybreResult, which will be serialized with JSON.net as a return value

Within these actions users can do what they like with the given database. Currently the only way to get these actions into the database by compiling them along with the database itself.

Example

using System.Linq;
using HybreDb.Actions.Result;
using HybreDb.Relational;
using HybreDb.Tables;

namespace HybreDb.Actions {
    public class HybreActionAll : IHybreAction {
        public HybreResult Execute(Database db) {
            var res = new HybreUniformResult();
            foreach (Table t in db) {
                res.Add(t, t.Rows.Select(e => e.Value));

                foreach (Relation rel in t.Relations)
                    res.Add(rel, rel.Table.Rows.Select(e => e.Value));
            }

            return res;
        }
    }
}

Clone this wiki locally