help with linq RRS feed

  • Question

  • please i need some help with linq

    i am really new in the subject

    i got this code

             public List<PresupuestoEN> ListarPresupuestoPendiente()
                 IPresupuestoDAO presupuestoDao = new PresupuestoDAO();
                 List<PresupuestoEN> listaPresupuestoPendiente = new List<PresupuestoEN>();
                 foreach (PresupuestoEN Model in presupuestoDao.GetAll().Where(
                       b => b.Estado == 21).ToList())
                 if (listaPresupuestoPendiente == null || listaPresupuestoPendiente.Count() == 0)
                     throw new Exception(MENSAJE_BUSQUEDA_NO_ENCONTRADA);
                 //return new JavaScriptSerializer().Serialize(listaPresupuesto);
                 return listaPresupuestoPendiente;

    but i notice then this allways generate 4 queries for ths , the 

    PresupuestoEN got this properties

     public virtual InformeAccidenteEN InformeAccidente { get; set; }
            public virtual ICollection<DetallePresupuestoEN> DetallePresupuesto { get; set; }

    I am not available to avoid the query for this entities who are really tables

    InformeAccidenteEN ,
    Thursday, January 22, 2015 12:30 PM


  • Hello Augusto,

    >>but i notice then this allways generate 4 queries for ths , the

    Does the query return the wrong result? If the result is correct, I think this should be by designed in the LINQ2SQL provider for translating LINQ to sql statement. Since we do not know exactly what you want, we can only provide some information about the LINQ2SQL which might be helpful to you:

    LINQ to SQL: .NET Language-Integrated Query for Relational Data

    101 LINQ Samples


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 23, 2015 3:40 AM