I am working on an [ASP.NET MVC](http://en.wikipedia.org/wiki/ASP.NET_MVC_Framework) application which uses the repository pattern with [LINQ to SQL](http://en.wikipedia.org/wiki/Language_Integrated_Query#LINQ_to_SQL_.28formerly_called_DLINQ.29) as my data source. In my repository I expose the following method:

```
public IEnumerable<T> Find(Expression<Func<T, bool>> where)
{
    return _context.GetTable<T>().Where(where);
}

```

I am able to call this by saying:

```
repository<User>().Find(u => true);

```

But if I try doing (when search is null)

```
repository<User>().Find(u => !string.IsNullOrEmpty(search) ? u.UserName.Contains(search) : true);

```

I get the error:

> 
> Value cannot be null. Parameter name: text
> 
> 
> 

I thought the lambda expression would execute the same thing since the value of search is null, but this is clearly not the case.

How do I fix this problem?