Print Page | Close Window

Query Search Many to many

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2215
Printed Date: 13-Mar-2025 at 5:39pm


Topic: Query Search Many to many
Posted By: bala
Subject: Query Search Many to many
Date Posted: 06-Oct-2010 at 6:52am
Hi There

I have one problem in searching recrods

When I search record first time it return nothing in first click but second click
it returning the records...
I using following code.
Where Is Mistake?

 ObservableCollection<PESSOA_PROFISSAO> Profissoes = new ObservableCollection<PESSOA_PROFISSAO>();

_em.PESSOA_PROFISSAO_GRUPOS.Where(f => f.ID_PESSOA_PROFISSAO_GRUPO == PessoaProfissaoGrupo.ID_PESSOA_PROFISSAO_GRUPO).ExecuteAsync(op =>

         {
             if (op.IsCompleted)
             {
                 op.Results.FirstOrDefault().PESSOA_PROFISSAO.ForEach(Profissoes.Add);

                 agDataGrid3.DataSource = Profissoes;

             }
             else
             {

                 MessageBox.Show(op.Error.Message);
             }
         });

Thanks



Replies:
Posted By: DenisK
Date Posted: 06-Oct-2010 at 11:12am
Hi Bala;

Could you try and change your query as follows

_em.PESSOA_PROFISSAO_GRUPOS
.Where(f => f.ID_PESSOA_PROFISSAO_GRUPO == PessoaProfissaoGrupo.ID_PESSOA_PROFISSAO_GRUPO)
.Include(f => PESSOA_PROFISSAO)
.ExecuteAsync(op =>

{

//Rest of the code here

});


Posted By: bala
Date Posted: 08-Oct-2010 at 12:07pm
Hi Denis

Thanks for help.. This code works..





Print Page | Close Window