开发者

Whats wrong with my Nhibernate HQL query?

I have this

public List<TableA> GetRecords(List<string> keys)
    {
        const string query = "FROM TableA WHERE `Key` = :keys";
        return session.CreateQuery(query).SetParameterList("keys",keys).List<TableA>().ToList();
    }

I get it could not execute error "could not execute query"

when I look at it my where clause is always equal to "?" . So it's like not using my list to fill it in.

Edit

If I have this

List<strings> myKeys = new List<strings> {"1", "2"};
GetRecords(myKeys)

It will fail

If I have

List<strings> myKeys = new List<strings> {"1"};
GetRecords(myKeys)

It works. So it can't handle for some reason more th开发者_如何学Goan one value.


You should have "in" instead of "="

const string query = "FROM TableA WHERE Key in (:keys)";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜