I’m not able to call take method from below linq query
var data = from tb in table.AsEnumerable()
join ch in channelTable.AsEnumerable() on syskey equals (DateTime)ch["syskey"]
orderby Convert.ToDouble(tb[(string.Format("Channel{0}_data",Convert.ToInt32(ch["Channel_No"])))]) descending
select new
{
Channel_No = ch["Channel_No"],
Channel_data = tb[string.Format("Channel{0}_data", Convert.ToInt32(ch["Channel_No"]))],
};
How can I add Take(5) from above linq query?
As simply as:
You can do it in the same statement, too, but it’s a bit ugly:
Note that ordering by a string here probably doesn’t do what you want, unless your values are all single digit – would you really want channel3, channel2, channel10, channel1?
It’s a pretty odd query though – especially as your join doesn’t use anything from the first table…