How to do foreach on each select using EF6?

1

Follow the code:

var list = new List<String>();
list.Add("Casa");
list.Add("Apartamento");

var connection = ctx.Table.Where(x => x.Tipo== list).ToList();

My database:

+=============================================+
|      Tipo     |    TBName   |    Número     |
+=============================================+
| Sandwich Type | Turkey Club |            10 |
| Casa          | Italian     |             5 |
| Casa          | Garlic      |             8 |
+---------------------------------------------+
    
asked by anonymous 17.03.2017 / 02:40

1 answer

2

The solution I found was:

First you list everything and then you apply the filter.

var list = new List<String>();
list.Add("Casa");
list.Add("Apartamento");

var connection = ctx.Table.ToList().Where(x =>list.Contains(x.Tipo)).ToList();
    
17.03.2017 / 02:50