Click here to Skip to main content
15,921,660 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
See more:
I have two list's.
1: List of tree nodes. {e.g.: Property: Text = FileName.txt}
2: List of file objects. {e.g.: Property: Name = FileName.txt}

How would I create a new filter using "findall"? Below is what I have and it doesn't work. In-other-words: I'm trying to find matching properties from two different list.

Thank you in advance.

List<ADSK.File> _vFileFilter = _vFilesList.FindAll(x => _nodeList.FindAll(y => x.Name.Contains(y.Text)) );
Posted
Comments
Sergey Alexandrovich Kryukov 24-Sep-12 15:55pm    
This is not a fully formulated question so far. First, you need to show the declarations of all lists, apparently. Then you need to formulate your search criteria exactly. Most likely, you would need to have two separate FindAll. Alternatively, you would need to merge two lists on some common container and perform FindAll on it.
--SA
Zoltán Zörgő 24-Sep-12 15:58pm    
It is not clear what you want. Finding "matching properties of two lists makes" makes no sense to me, and the query you posted could mean a completely other thing.
Please think of your lists as tables, can you formulate your query as an sql statement?
Sergey Alexandrovich Kryukov 24-Sep-12 16:07pm    
Right. This is actually simple: "matching properties..." should be some predicate function taking some properties from both list (according to OP, "different types") and calculating the return Boolean value according to some criteria. Whatever it is, OP should supply it, formally or informally. The code line shown right now is something different, leaving a room for some guesswork, but why? Declaration of the two lists is also required. As simple as that. But I basically already answered what can it boil down to, above...
--SA

List<ADSK.File> _vFileFilter = _vFilesList.FindAll(x => _nodeList.Contains(n => n.Name == y.Text) );
 
Share this answer
 
v2
try:
C#
List<ADSK.File> _vFileFilter  = (_vFilesList.Where((x, i) => x.Name.Contains(_nodeList[i].Text))).ToList();
 
Share this answer
 
v4

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