Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm querying a view and filtering the results with a column named status. I'd like to query it so I can search for rows with different status, by using the IN operator as I'd do in SQL.

As so:

SELECT * FROM VIEW WHERE Status in ('....', '.....')

How can I achieve this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
240 views
Welcome To Ask or Share your Answers For Others

1 Answer

If your query expression uses the Contains method of an IEnumerable object, the parser will turn that into an IN expression using the values in the IEnumerable.

List<string> foo = new List<string>() { "a", "b", "c" };

var query = dataContext.View.Where(v => foo.Contains(v.Status));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...