var Charts = chartGroup
.Descendants("charts")
.Elements("chart")
.Where(x => x.Attribute("id").Value == chartId.ToString())
.Select(x => x.Attribute("name").Value).ToList();
Here I want to use an "in-clause"" (like the in
clause in SQL) for Attribute("id").Value
for array of strings:
like:
Where(x => x.Attribute("id").Value in ("1","2")
Where(x => x.Attribute("id").Value` in charIds[]
how to achieve this?
SQL Where – In
Functionality can be easily achieved by Lambda Expression.
SQL query -
Select Name,Id from Category Where Id In (71,72)
Lambda Expression –
List checkedRecords = new List { 71, 72 };
var Cs = Context.Categories.Where(c => checkedRecords.Contains(c.Id));
I Hope this would help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With