Where(x => "my constant string".Contains(x.MyProp)) throws System.InvalidOperationException : Expression argument must be of type ICollection.

Description

The following test fails with an exception: "System.InvalidOperationException : Expression argument must be of type ICollection." The Where clause is intended to translate to the SQL "where 'ayende rahien' like '%u.Name%'" This is reversed from usual Like usage, but is helpful for certain kinds of wildcard searches. Linq to SQL exposes a raw SQL interface with SQLMethod.Like(x, y). An interface along those lines for NHibernate.Linq could also work fine for this application.

[Test]
public void StringWithUsersContains() {
var query = (from user in session.Linq<User>()
where "ayende rahien".Contains(user.Name)
select user).ToList();
Assert.AreEqual(2, query.Count);
}

Environment

None

Activity

Show:

Details

Assignee

Reporter

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created September 16, 2009 at 1:41 PM
Updated September 16, 2009 at 1:41 PM
Who's Looking?