0

Please can someone assist.

I am wanting to filter a list of items based on another list.

I have a list of Electronics Device Models.

I have and add function which allows the user to add models to the list.

Within the Add function I have a combo box which contains all of the possible Models in my database.

I want to be able to filter the Items in the Combo Box to ensure that the user cannot select a Model that is already in the list.

I thought I could do this as a Lambda expression, but it seems there is not a NOT IN function available?

Richard Gale
  • 1,816
  • 5
  • 28
  • 45
  • 1
    I think you're looking for the [Enumerable.Except Method](http://msdn.microsoft.com/en-us/library/vstudio/system.linq.enumerable.except%28v=vs.100%29.aspx). – Andrew Morton Oct 28 '14 at 11:23
  • Can the except method be used on a particular element of the class or is exact match only? In my case, I would like to be able to compare ModelID only, as other elements of the model may have changed. – Richard Gale Oct 28 '14 at 11:28

1 Answers1

1

Have you tried to use the Except method?

Produces the set difference of two sequences by using the default equality comparer to compare values.

Remy Baratte
  • 316
  • 5
  • 14
  • Can the except method be used on a particular element of the class or is exact match only? In my case, I would like to be able to compare ModelID only, as other elements of the model may have changed. – Richard Gale Oct 28 '14 at 11:29
  • @Richard As readable in the documentation it uses the standard equality comparer. I am not sure if you can override this in VB.NET. – Remy Baratte Oct 28 '14 at 11:31
  • OK, in principle it does what I am wanting, I will edit how I update my Models so that an exact match can be achieved. Many thanks. – Richard Gale Oct 28 '14 at 11:38
  • @Richard No problem, the comments of the documentation contain some information for custom comparison, but it seems to be a bit unclear. – Remy Baratte Oct 28 '14 at 11:40