Visually Located


Using the Repository Pattern with ArcObjects

The Repository Pattern is well known to everyone that needs to access a database. That is unless you access a database through ArcObjects. A repository is easy to use, easy to inject, and easy to unit test. Doing anything with ArcObjects is very complicated. Especially unit test. Wrapping ArcObjects in a layer of abstraction usually helps simplify things. By wrapping a few simple operations within a repository, your code no longer needs to start or stop an edit operation, no longer needs to worry about creating a QueryFilter (something that cannot be done within unit tests), and no longer needs to worry about all of the little details of accessing ArcObjects. Let’s start with a simple repository using ArcObjects. We’ll need the normal CRUD operations. interface ITableRepository { IRow GetById(int id); IEnumerable<IRow> GetAll(); IEnumerable<IRow> GetByWhere(string whereClause); void Delete(IRow entity); int Save(IRow entity); void BeginTransa... [More]