locked
BeginExecute and foreach problem RRS feed

  • Question


  • foreach (TURNO t in listaTurnoPersona) { var id = t.ID_TURN; DataServiceQuery<VST_CANTIDAD_PERSONAS_POR_DIA> query = General.Entities.VST_CANTIDAD_PERSONAS_POR_DIA.Where( z => z.ID_TURN == id && z.FE_CALE >= RadDatePicker1.SelectedDate.Value && z.FE_CALE <= RadDatePicker1.SelectedDate.Value.AddDays(6)) as DataServiceQuery<VST_CANTIDAD_PERSONAS_POR_DIA>; query.BeginExecute(ar => { //here the url change the ID_TURN, but the always return the same id_turn- var ff = query.EndExecute(ar); // at this point you can resume the logic. }, null); }
    This worked before but now im getting the same result for every iteration, what could be wrong??? THE URI of the dataservice query change the ID_TURN but ion the result always return the same. AND while debugging the query i realized that the entity VST_CANTIDAD_PERSONAS_POR_DIA is only created the first time that i call EndExecute. Help!!!
    Make it Ice
    Thursday, July 23, 2009 7:09 PM

Answers

  • Resolved :D the problem was that i was creating globally the entities, now i put it this way and is working :
    foreach (TURNO t in listaTurnoPersona)
                {
    
                    var id = t.ID_TURN;
    
                    DataServiceQuery<VST_CANTIDAD_PERSONAS_POR_DIA> query = new Entities(new Uri("Services/WebDataServiceSiata.svc", UriKind.Relative)).VST_CANTIDAD_PERSONAS_POR_DIA.Where(
                        z => z.ID_TURN == id
                            && z.FE_CALE >= RadDatePicker1.SelectedDate.Value
                            && z.FE_CALE <= RadDatePicker1.SelectedDate.Value.AddDays(6)) as DataServiceQuery<VST_CANTIDAD_PERSONAS_POR_DIA>;
    
    
                    query.BeginExecute(ar =>
                    {
    //here the url change the ID_TURN, but the always return the same id_turn-
                       var ff =  query.EndExecute(ar);
                        // at this point you can resume the logic.
                    }, null);
    
                }
    



    Make it Ice
    Thursday, July 23, 2009 7:50 PM