Пример #1
0
        protected static DBOCollection ExecuteSelectQuery(String connectionString, DBOSql instance, string cmdTxt, SqlParameter[] parameters)
        {
            DataTable dt = DataAccessSql.ExecuteDataTable(connectionString, CommandType.Text, cmdTxt, parameters); //Ejecutamos la consulta y obtenemos el DataSet correspondiente.

            //Preparamos un contenedor para los resultados, es decir, una lista.
            DBOCollection rowList = (DBOCollection)instance.getCollection();

            foreach (DataRow row in dt.Rows) //Para cada uno de los registros obtenidos...
            {
                DBOSql dbo = (DBOSql)instance.getObject();
                dbo.FillObjectFromDataRow(dt, row);
                //Añadimos el objeto a la lista (contenedor).
                rowList.Add(row[instance.idColumn].ToString(), dbo);
            }

            return(rowList); //Devolvemos la lista .
        }
Пример #2
0
        public static DBOCollection getAll(DBOSql instance, string where, string order, bool ascending, List <SqlParameter> param)
        {
            string cmdTxt = "SELECT * FROM " + instance.strTabla;

            if (where != null && where != "")
            {
                cmdTxt += " WHERE " + where;
            }
            if (order != null && order != "")
            {
                cmdTxt += " ORDER BY " + order;
                if (ascending)
                {
                    cmdTxt += " ASC";
                }
                else
                {
                    cmdTxt += " DESC";
                }
            }
            return(ExecuteSelectQuery(instance, cmdTxt, param.ToArray()));
        }
Пример #3
0
 protected static DBOCollection ExecuteSelectQuery(DBOSql instance, string cmdTxt, SqlParameter[] parameters)
 {
     return(ExecuteSelectQuery(Constantes.sqlConnectionString, instance, cmdTxt, parameters)); //Ejecutamos la consulta y obtenemos el DataSet correspondiente.
 }