WEB API 2 IQueryable IN Query

时间:2015-04-20 06:10:22

标签: sql-server entity-framework asp.net-web-api2 iqueryable

在WEB API 2中如何使用IN Query 从SQL字符串:

select * from TABLE where state in (x)

// GET: api/TABLE
public IQueryable<TABLE> GetTABLE(string x)
{
    return db.TABLE.Where(c => c.state.Contains(x));
}

1 个答案:

答案 0 :(得分:1)

这样的事情应该有效:

public IQueryable<TABLE> GetTABLE(string x)
{
    var l = new List<string>() {x};

    return db.TABLE.Where(c => l.Contains(c.state));
}