Verify a collection value

  • Thread starter Thread starter roberta
  • Start date Start date
R

roberta

I've this code

Dipendente myDipendente = new Dipendente();
myDipendente = DipendenteManager.GetItem(IDDipendente, true,
true, true, true);

Now in

myDipendente.Elenco I've an ElencoCollection

Now I would like to verify if in my collection (Elenco) there is, for
the field Elenco.ID the value 10... is it possible?

Thanks
 
roberta said:
I've this code

Dipendente myDipendente = new Dipendente();
myDipendente = DipendenteManager.GetItem(IDDipendente, true,
true, true, true);

Now in

myDipendente.Elenco I've an ElencoCollection

Now I would like to verify if in my collection (Elenco) there is, for
the field Elenco.ID the value 10... is it possible?

Thanks

Yes you can query the collection using Linq.

var myobject = (from a in myDipendente.Elenco where a.ID == 10 select
a).firstordefault();

if (myobject != null)
{
var id = myobject.ID;

}

http://en.wikipedia.org/wiki/Language_Integrated_Query
 
roberta said:
Can you tell me how Can I do this without using Linq?

Thanks

You make a bool function put into a foreach loop on the collection until
you get the hit I guess.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top