Verify a collection value

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
 
M

Mr. Arnold

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
 
M

Mr. Arnold

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top