Ejemplo n.º 1
0
        public EntityRepository ExecuteSql(DataService Service, int CommandTimeout)
        {
            return((EntityRepository)Execute(Service, (DbConnection, DbCommand) =>
            {
                String sql = DbCommand.CommandText;

                Service.Parameters.ForEach((parameter) =>
                {
                    sql = sql.Replace("{" + parameter.Name + "}", parameter.Value.ToString());
                });
                DbCommand.CommandText = sql;


                DbCommand.CommandType = System.Data.CommandType.Text;

                System.Data.IDbDataAdapter adapter = (System.Data.Common.DbDataAdapter)Activator.CreateInstance(typeof(TAdapter));

                System.Data.DataSet ds = new System.Data.DataSet();
                adapter.SelectCommand = DbCommand;
                adapter.Fill(ds);
                EntityRepository Repository = new EntityRepository(ds);

                return Repository;
            }, CommandTimeout));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Ejecuta una accion contra la DB y devuelve el resultado de esta bajo un esquema de repositorio (configuracion a traves del Services.xml)
        /// </summary>
        /// <param name="Service">Servicio de Datos</param>
        /// <param name="CommandTimeout">Tiempo de espera para que la ejecucion retorne la respuesta</param>
        /// <returns>Repositorio de entidades</returns>
        public EntityRepository ExecuteQuery(DataService Service, Int32 CommandTimeout)
        {
            return((EntityRepository)Execute(Service, (DbConnection, DbCommand) =>
            {
                System.Data.IDbDataAdapter adapter = (System.Data.Common.DbDataAdapter)Activator.CreateInstance(typeof(TAdapter));

                System.Data.DataSet ds = new System.Data.DataSet();
                adapter.SelectCommand = DbCommand;
                adapter.Fill(ds);
                EntityRepository Repository = new EntityRepository(ds);

                return Repository;
            }, CommandTimeout));
        }