예제 #1
0
 void it_AlEncontrarRelacion(ref Armador arm, Relacion r, PropertyInfo pi, object val)
 {
     Relacionado rc = new Relacionado
     {
         CampoId = r.CampoId,
         CampoSecundario = r.CampoSecundario,
         Destino = r.Destino,
         Where = r.Where,
         Nombre = pi.Name,
         PermitirNull = r.PermitirNull
     };
     arm.AgregarRelacion(rc);
 }
예제 #2
0
        internal void AgregarRelacion(Relacionado r)
        {
            if (this.Consultar != null)
            {
                Relaciones.Add(r);
                var matcheador = new ArmadorFactory(this.Consultar).CreateFromClass(r.Destino);
                string select;

                if (r.ExisteCampoDisplay)
                {
                    select = string.Format(
                        "d.{0}, d.{1}",
                        matcheador.Atributos[r.CampoId].Nombre,
                        matcheador.Atributos[r.CampoSecundario].Nombre);
                }
                else
                {
                    select = string.Format("d.{0}",
                        matcheador.Atributos[r.CampoId].Nombre);
                }

                DataSet ds;
                //if (r.Where.Equals(""))
                //{
                ds = matcheador.Consultar(string.Format("SELECT * FROM {0}", matcheador.Nombre));
                //}
                //else
                //{
                //    ds = matcheador.Consultar(string.Format(
                //    "SELECT {0} FROM d.{1}, o.{2} WHERE {3};", "d.*", matcheador.Nombre, Nombre, r.Where.Replace("{d}","d").Replace("{o}","o")
                //    ));
                //}

                foreach (ArrayList objeto in DataSetProcessor.GetTotalObjetos(ds)) // Code from Armador.CargarInstancias
                {
                    matcheador.InstanciaAsociada = null;
                    matcheador.AsignarAtributos(objeto);
                    matcheador.CopyToInstance();
                    List<Atributos> atributos = new List<Atributos>();
                    foreach (Atributos at in matcheador.Atributos)
                    {
                        atributos.Add(at.Clone());
                    }
                    r.Resultados2.Add(atributos);
                    r.Resultados.Add(
                        matcheador.Atributos[r.CampoId].Valor,
                        matcheador.Atributos[r.CampoSecundario].Valor.ToString());

                }
            }
        }