|
I have a list of filter names: FILTERBYNAMES
my query result items each contain a name list: NAMES
I want to filter the result an take all items whose name list contains at least one name in the FILTERNAMELIST:
results= result.where(r=>r.NAMES.CONTAINS...
Started by zsharp on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
HashSet<string> hashedFilter = new HashSet<.
FilteredResult = result.Where(i => i.Names.Intersect(filter).Any());
To limit the enumerations of the filter, you could use a hashset...
|
|
Using Python how do you reduce a list of lists by an ordered subset match [[..],[..],..] ?
In the context of this question a list L is a subset of list M if M contains all members of L , and in the same order. For example, the list [1,2] is a subset of...
Started by Oliver on
, 11 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Except ValueError: return False else: return True def filter_subsets(lists): """ Given list of lists, 4, 5, 6], [1, 2, 3], [2, 3, 21], [1, 2, 3, 4], [1, 2, 3, 4, 5, 6, 7]] print list(filter_subsets(my-liner:
....
|
|
I need to filter a strongly typed list of type StaffingPositionsDataContract, with another list of filter names and values. I have these two lists:
List<SerializedForm> deserializedObject = JsonConvert.DeserializeObject<List<SerializedForm...
Started by Zacho on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Var filter in filters) { foreach (var contract in contracts) { PropertyInfo info = typeof.
|
Ask your Facebook Friends
|
Hi,
I have a List of string objects which represent process names. I want to filter a collection of running Processes (retrieved by using GetProcesses()), by using the list of string objects I have. So if I want to look for the Sql Server process running...
Started by dotnetdev on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Var targetNames = new [] { "chrome....
Var targetNames = new [] { "processone", "Processtwo" }; var processes = from p in Process.GetProcesses() where targetNames.Any(n => n == p.ProcessName) select p;
Or using LINQ's join clause.. .
This should do it..
|
|
Possible Duplicate:
Java: What is the best way to filter a Collection?
Hi,
I'm doing some collection filtering, my actual code looks like this:
List<Item> filtered_list = new List<Item>(); for(Item it : original_list){ if(it.isSpecial) filtered...
Started by Pablo Fernandez on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
This would be nicer if Java supported lambda expressions of course for a single use, but if you need to use the same sort of filter (or projection, or whatever) logic than, say, copying the entire....
Iterable<T> to create a new list.
|
|
I have the following class in my C# .NET 3.5 win forms app:
class Field { string objectName; string objectType; string fieldName; string fieldValue; }
and a List fieldList that is a datasource for a checkedlistbox. This listbox shows all the distinct ...
Started by Alex on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Then it should be something like:
string.
// List of selected names var selectedFields = (from f in fieldList where names into an array or list; I'll fake that part.
Var selectedNames = ...
|
|
I've a problem!
I've a
List <List<Class>> L = new List<List<Class>>();
where Class contains
IDLinea Posizione
And so on...
I want to have a Distinct List<List<Class>> Where there are no objects with same lines.
For ...
Started by Giomuti on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Edited based) // but not relevant to current question return x.Sum(c => c.IDLinea); } } // assume List <.
Use the Contains method of the list.
Use a List Have your class ovveride Equals.
|
|
Say I have two lists:
let a = [1 .. 1000] let b = [250 .. 500]
How do I get a new list that contains the values {1-249, 501-1000}?
Started by Austin Salonen on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Since your list is sorted, you can of your output, you can just do:
(Set.of_list a) - (Set.of_list b) |> Set.to_list
If you know.
Will be an instance of IEnumerable<int> though and not an F# list.
|
|
I'm just getting my feet wet with LINQ. Given three lists of items, this is what I've come up with to only show ClassA items that are referenced in the list of ClassB items but not in the list of ClassC items.
var uniqueClassAIDsInClassB = (from classB...
Started by jball on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
For efficiency, you might want to create an A.ID list first.
Your solution is fine.
Hard to read...
|
|
Django doesn't support getting foreign key values from list_display or list_filter (e.g foo__bar). I know you can create a module method as a workaround for list_display, but how would I go about to do the same for list_filter? Thanks.
Started by Dan on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Well, the docs say that you can may use ForeignKey field types in list_filter :
http(Foo) # admin.py: class BarAdmin(admin.ModelAdmin): list_filter = ('foo')
If you want to filter://docs.djangoproject.com/en/dev/ref/....
|