views:

30

answers:

0

any helper class for reduce code lines using ent Library ??

for example, I have this code, can I use reduce lines using any helper class ?? Any sample please

        Database db = DatabaseFactory.CreateDatabase("ConnectionStrings.Oracle.D04PES01");
        using (DbCommand cm = db.GetStoredProcCommand("TBL_POC_TEST_TIPOS.TBL_POC_TEST_TIPOS_FBY_PK"))
        {
            db.AddInParameter(cm, "P_ID_TEST_TIPOS", DbType.String, id);
            cm.Parameters.Add(CreateCursorParameter("P_REFCURSOR"));

            // Using "using" will cause both the DataReader and connection to be 
            // closed. (ExecuteReader will close the connection when the 
            // DataReader is closed.)
            using (IDataReader dataReader = db.ExecuteReader(cm))
            {
                if (dataReader.Read())
                {
                    factory.Add(dataReader);
                }
                //while (dataReader.Read())
                //{
                //    factory.Add(dataReader);
                //    break;
                //}
                return factory.Entity;
            }
        }