Question: I building my first application with c# and sp.net MVC 5, so far so good :)

Now I have a problem, we using 2 User Tables, first one contains the username, other the user data.

```
string user = User.Identity.Name;

        var data = db.FE_Benutzer;
        var collection = data.Where(o => o.Benutzername == user).Select(x => new
        {
            id = x.ID,
            name = x.Name,
            hauptbereiche = x.Hauptbereich.ToList()
        });

        var dataHauptbereich = db.Hauptbereich;

        var collectionHauptbereich = dataHauptbereich.Where(o => collection.ElementAt(0).hauptbereiche.Contains(o)).Select(x => new
        {
            id = x.ID,
            name = x.Name
        });

        return Json(collectionHauptbereich, JsonRequestBehavior.AllowGet);

```

I getting this error

> 
> LINQ to Entities does not recognize the method '<>f\_\_AnonymousType6`3[System.Int32,System.String,System.Collections.Generic.List`1[scorring.Models.Hauptbereich]] ElementAt[<>f\_\_AnonymousType6`3](System.Linq.IQueryable`1[<>f\_\_AnonymousType6`3[System.Int32,System.String,System.Collections.Generic.List`1[scorring.Models.Hauptbereich]]], Int32)' method, and this method cannot be translated into a store expression.
> 
> 
> 

hauptbereiche = x.Hauptbereich.ToList()

contains a list of ids where the user have premission to.

When I fetching the data

dataHauptbereich.Where

I wont to include only the ids I have in the list

how is this possible?

Answer: 
Entity Framework doesn't know how to turn `ElementAt` into SQL. See this answer for more information: [Getting the first result from a LINQ query - why does ElementAt<T>(0) fails when First<T>() succeeds?](https://stackoverflow.com/questions/2650150/getting-the-first-result-from-a-linq-query-why-does-elementatt0-fails-when)
Try

```
dataHauptbereich.Where(o => collection.ElementAt(0).hauptbereiche.Any(h => h.ID == o.ID))

```

Or

```
dataHauptbereich.Where(o => collection.Any(c => c.hauptbereiche.Any(h => h.ID == o.ID)))

```