title: How do I integrate ODP.NET into Repository classes?
body: <p>My domain model provides e.g. following object <code>Report : IEntity&lt;Report&gt;</code>.
  I usually retrieve Oracle user defined type object (or collection types) form stored procedures. For all types C# classes are generated by the ODP.NET Visual Studio Custom Class Wizard. So I have following class e.g.:</p>
  
  <pre><code>public class UDT_REPORT : INullable, IOracleCustomType, IXmlSerializable {
      private bool m_IsNull;
      private decimal m_REPORT_ID;
      private decimal m_VALUE;                
      // etc
  }
  </code></pre>
  
  <p>Currently I'm trying to create a new data access layer for a C# application. I would like to apply the repository pattern in this case in order to achieve loose coupling and better testability. But how to integrate these generated classes into repositories? How to design the <code>ReportRepository</code> class?</p>
  
  <pre><code>public interface IReportRepository
  {         
      Report Find(ReportId id);
      IList&lt;Report&gt; FindAll();
      void Store(Report Report);
  }
  </code></pre>
  
  <p>Should I use following approach?
  A static DB proxy class that e.g. exposes a generic <code>Read&lt;T&gt;()</code> method with a given delegate for data retrieval and mapping. And a factory for creating the db provider.</p>
  
  <pre><code>public static T Read&lt;T&gt;(string sql, Func&lt;IDataReader, T&gt; fetch, object[] parms = null)
  {
      using (var connection = factory.CreateConnection())
      {
          connection.ConnectionString = connectionString;
  
          using (var command = factory.CreateCommand())
          {
              // Add connection; sql command text; 
                       // add parameters via some extension method   
              // Open and close connection                                                                         
              T t = default(T);
              var reader = command.ExecuteReader();
              if (reader.Read()) {
                  t = fetch(reader);
              }
              return t;
          }
      }
  }
  </code></pre>
  
  <p>And following delegate is used for fetching the related UDT object and mapping it to the domain object e.g. <code>Report</code>. </p>
  
  <pre><code>private static Func&lt;IDataReader, Customer&gt; Fetch = reader =&gt;
  {                                             
              UDT_REPORT report = reader.GetValue(reader.GetOrdinal("out_param_report"));
              Report report = Mapping.Map(reportEntity);          
              return report;
  };
  </code></pre>
  
  <p>What do you think about this approach? Are there better approaches for integrating ODP.NET types in Repositories? Or should I avoid generated UDT classes and add some ORM frame instead?</p>