Question: ```
departments = (from p in _context.DateSnippets
                               where query.UserInfo.Departments.Contains(p.DepartmentId)
                               group p by p.DepartmentId
                                   into g
                                   select new Tuple<int, DateTime>(g.Key, g.Max(x => x.FromDate))
                               ).ToList();

```

I get the following exception for 

> 
> Contains() method
> 
> 
> 

Here's the exception 

```
An exception of type 'System.NotSupportedException' occurred in mscorlib.dll 
but was not handled in user code
Additional information: Only parameterless constructors and 
initializers are supported in LINQ to Entities. 

```

Answer: 
The problem is here:

```
new Tuple<int, DateTime>(g.Key, g.Max(x => x.FromDate)

```

Unfortunately when you execute this against database, it won't work because you can not pass parameters in constructors. one of the many workarounds could be using an object 

```
new MyData {Key = g.Key, Date = g.Max(x => x.FromDate)}

```
Change the `Contains` to an `Any`

```
where query.UserInfo.Departments.Any(d => d.DepartmentId == p.DepartmentId)

```

Change the Select to projecting to an annoymous class or poco. The error explicitly states you can not have parameters in the constructor

```
 select new 
 {
  g.Key,
  g.Max(x => x.FromDate)
 }

```