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 anIEnumerable
just like I need but the int开发者_开发知识库erface 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?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.
精彩评论