Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello people,

I'm need LINQ join with MyCollection and List<string>

like this:

C#
FieldsCollection fields = new FieldsCollection();
List<String> columns = new List<String>();

FieldsCollection query = (from f in fields
join c in coluns on f.value equals c
select new Field(){
   Key = f.key,
   Alias = f.Alias
}).Cast<FieldsCollection>();

please consider that the objects are populated.
and i want return a FieldsCollection;

thanks everbody
Posted
Comments
Karthik_Mahalingam 15-Jan-14 13:00pm    
what is FieldsCollection object ??
EduChapow 15-Jan-14 14:50pm    
that's my collection i create it.

public class FieldsCollecion : Collection<field>
{}

1 solution

Try like this, might help you.

C#
FieldsCollection query = new FieldsCollection ();
           (from f in fields
            join c in columns on f.value equals c
            select new Field()
            {
                Key = f.key,
                Alias = f.Alias
            }).ToList().ForEach(k => query.Add(k));
 
Share this answer
 
Comments
EduChapow 15-Jan-14 14:03pm    
that is work man! thank you.

but i use foreach statement anyway! i really prefer a cast! but this resolve my problem.
Karthik_Mahalingam 15-Jan-14 22:14pm    
Thanks Dude :)
Maciej Los 15-Jan-14 16:48pm    
Worth a 5!
Karthik_Mahalingam 15-Jan-14 22:14pm    
Thanks Maciej :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900