Question: **I have 2 a classes:**

```
public enum ArticleType
{
  News = 1;
  SpecialOffer = 2;
  Service = 3;
}

public ArticleApiDto
{
  public int Id;
  public ArticleType Type;
}

```

Now i have method for getting data from db, something like:

```
public List<ArticleApiDto> GetAll(List<ArticleType> types)
{
  var res = new List<ArticleApiDto>();
  res = context.articles.ToList();
  //do stuff
}

```

Now I would like to filter out Articles from **res** whose **type** is specified in **types** from parameter of method.

**Problem 1:** I actually cant use Contains because ArticleType is enum

**Problem 2:** `List<ArticleType>` is because sometimes i want to pass only one type but sometimes two or three. At the moment i cant figure out better better solution.

Can someone help me with this please I was searching for whole noone but cant figure out

Answer: 
To be able to pass more than one type you can do it like:

Make your enum to be Flags (note that values now can't be 1,2,3,4 and should be 1,2,4,8,16,...:

```
[Flags]
public enum ArticleType
{
  News = 1;
  SpecialOffer = 2;
  Service = 4;
}

```

Now you add up what you want to filter with `|`:

```
filter = ArtickeType.News | ArticleType.Service;
var result = res.Where(x => filter & x.Type != 0).ToList();

```

or:

```
filter = ArtickeType.News | ArticleType.Service | ArticleType.SpecialOffer;
var result = res.Where(x => filter.HasFlag(x.Type)).ToList();

```

To do it with your current enum:

```
public enum ArticleType
{
  News = 1;
  SpecialOffer = 2;
  Service = 3;
}

var filter = new List<ArticleType> { ArticleType.Service, ArticleType.News};
var result = res.Where(x => filter.Contains(x.Type)).ToList();

```
This code work with me, I use Linq with contains it may solve your problem.

```html
public static List<ArticleApiDto> GetAll(List<ArticleType> types)
        {
            var res = new List<ArticleApiDto>();
            List<ArticleApiDto> articles = new List<ArticleApiDto>
            {
                new ArticleApiDto{Id = 1, Type = ArticleType.News },
                new ArticleApiDto{Id = 2, Type = ArticleType.SpecialOffer },
            };

            var newArticales = articles.Where(i =>
            {
                return types.Contains(i.Type);
            }).ToList();
            return newArticales;
        }
```