Search code examples
c#activerecordcastle-activerecordweb-services

Generalizing a Fetch() function for data sources


I have a Repository that should adapt itself to any kind of data source.
This includes certain types of web services, databases (using ActiveRecord and NHibernate) and even flat files.
For ActiveRecord I have EnumerateQuery(IActiveRecordQuery query) which returns an IEnumerable just like I need but the interface is undocumented.
What exactly does it do? How do I use it?
Can I use it to extend my Fetch() function to accept other data sources?
Can I wrap it with my own class in order to accept other data sources?


Solution

  • I'd use IQueryable as an abstraction instead. Make your IRepository implement IQueryable, then the ActiveRecord repository would delegate to Castle.ActiveRecord.Linq, flat file repository would be implemented using LINQ to XML, etc.