Repository Classes

Repositories are the objects that gets the data from the database. In Crow FX this layer is automated by generating proxies. Repositories are just interfaces and they will be build when the applications first run. See simple example below;

    public interface IDataRepository
        void InsertData(Data data);
        Data GetDataById(int id);
        void UpdateData(Data data);

In this example, InsertData(Data) method is marked as an insert method and UpdateData(Data) is also marked as an Update method. This means you won't need to write the update, insert or delete queries in order to implement them. But on the hand there is a "Data GetDataById(int)" method without any mark. This means that this operation must be implemented and matched with a query on the application start up. We'll talk about this later.

Since repository interfaces in CrowFX doesn't need to be implemented by a concrete class, you have to get the instance by a factory method shown below;

  var repo = Repository.Get<IDataRepository>();

Repository.Get<TRepositoryType>(); dynamically generates a proxy object that implements the given interface. This class is also singleton and will not be built again after first load.

Last edited Aug 10, 2012 at 12:33 PM by msusur, version 2


No comments yet.