How to properly use array Contains() on an Array Type DataColumn

136 views Asked by At

I'm trying to match a string inside a DataRow that holds a string array. I was able to achieve that once the column type was only string, but now it's a string array per row.

The DataTable is a DataTable.Load(DataReader), so the columns types are automatically created.

I tried to change the field to r.Field<string[]> but was unable to get results. How can I properly match the string in an array inside a DataRow of a string[] DataColumn Type?

  var result = commandTable.AsEnumerable().Where
      (r => splittedMessage.Contains(r.Field<string>("Intent"))).Select(s => new
      {
        Command = s.Field<string>("Command"),
        Permission = s.Field<short>("Permission")
      }).First();

I appreciate if there is a way keep it in lambda.

0

There are 0 answers