How to foreach in each select using EF6?

Asked

Viewed 57 times

1

Follows 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 |
+---------------------------------------------+

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();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.