Reputation: 495
ASP.NET, C#
I was doing something like this. Just need to complete it somehow.
var c = (from c in courseObject where
c.Status.Contains(selectedListItems) select c);
Giving these conditions:
courseObject = c and has properties such as c.Name, c.Status, c.Description
selectedListItems is List that contains "Active,Inactive,Disabled" for example
Upvotes: 3
Views: 350
Reputation: 6890
There are several ways to accomplish what I assume you're trying to do.
You can revert the .Contains()
and make it look like this:
var c = (from c in courseObject where
selectedListItems.Contains(c.Status) select c);
or you could use an enum
instead the list that will contain your statuses.
Then your query could look something like this:
var c = (from c in courseObject where
c.Status == (int)yourEnum.Active || c.Status == (int)yourEnum.Inactive || c.Status == (int)yourEnum.Disabled
select c);
Upvotes: 2
Reputation: 2543
You're really close. You need to do this:
var c = (from c in courseObject where
selectedListItems.Contains(c.Status) select c);
Upvotes: 4