IDomainObjectFactory usage

Oct 7, 2010 at 1:37 PM

I recently upgraded to change set 52373 (from change set 14253). I encountered build problems surrounding my existing usage of the Find and FindOne methods, and determined that the signatures for these methods had changed. Find now uses IDomainObjectsFactory (vs. IDomainObjectFactory) and FindOne now uses ISimpleDomainObjectFactory (vs. IDomainObjectFactory) for their respective domainObjectFactory parameters.

I chose to reintroduce the previously used signatures for Find and FindOne, rather than refactor all of my existing factory classes to accomodate the breaking signature changes. Should the previously available method signatures have remained when the new signatures were introduced, or was this breaking change intended? At first glance it appears these signature changes may have been made, in part, to accomodate Oracle development.

Here are the methods I need. Thanks in advance for any comments:

        protected List<TDomainObject> Find<TIdentity>(
            ISelectionFactory<TIdentity> selectionFactory,
            IDomainObjectFactory<TDomainObject> domainObjectFactory,
            TIdentity identity)
        {
            List<TDomainObject> results = new List<TDomainObject>();

            using (DbCommand command = selectionFactory.ConstructSelectCommand(this.Database, identity))
            {
                IDataReader rdr = this.Database.ExecuteReader(command);
                {
                    try
                    {
                        this.ConfigureDataReader(rdr);
                        while (rdr.Read())
                        {
                            results.Add(domainObjectFactory.Construct(rdr));
                        }
                    }
                    finally
                    {
                        ConsumeUnretrievedCursors(rdr);
                        rdr.Dispose();
                    }
                }
            }
            return results;
        }

        protected TDomainObject FindOne<TIdentity>(
            ISelectionFactory<TIdentity> selectionFactory,
            IDomainObjectFactory<TDomainObject> domainObjectFactory,
            TIdentity identity)
        {
            TDomainObject result = default(TDomainObject);
            using (DbCommand command = selectionFactory.ConstructSelectCommand(this.Database, identity))
            {
                using (IDataReader rdr = this.Database.ExecuteReader(command))
                {
                    this.ConfigureDataReader(rdr);
                    if (rdr.Read())
                    {
                        result = domainObjectFactory.Construct(rdr);
                    }
                }
            }
            return result;
        }