Plugin Developer Discussion

Discussion for FogBugz Plugin developers

CGenericEntity proposal

It would be really nice to have an API for generic entities that behaved more like the other entity classes.

Suppose I implement IPluginDatabase, and as part of that I create a method called CreateEntityTable() that returns a CTable.

If there were a CGenericEntityFactoryApi class that was exposed by the CPluginApi class I could do this:

var entityapi = api.GenericEntityFactory(CreateEntityTable());

This would expose methods like CBugApi, CStatusApi, etc. So instead of datasets, I could work with entity objects. Instead of exposing dbfields as properties, they could be exposed in a dictionary.Instead of having to do work to determine either to insert or update, I could just Commit() it.

Additionaly, items could be loaded with a Load method.
Stefan Rusek Send private email
Tuesday, April 21, 2009
This does sound cool, but it's unlikely that we'll get to it before launch.

The FogCreek.Database project in PluginUtils has an ActiveRecord class that's built on top of the API.  There's no simple example of it in use, but we use it in the CustomFields plugin (see CustomField.was).  Basically you can do something like this:

class Foo : ActiveRecord
    public int ixFoo;

    [Field(Length=255, NotNull=True, DefaultVal=""]
    public string sFoo

    public Foo(CPluginApi api) : base(api) { }

and then you have a functioning entity object.
David Fullerton Send private email
Tuesday, April 21, 2009

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz