Linq and EpiDataViews

Hi All,

Is it possible to query EpiDataViews with Linq to get a limited set of rows/values?

For example, I am trying to get a distinct list of sales order numbers from shipment lines in Customer Shipment Entry.

I start with:
EpiDataView edvShipDtl = ((EpiDataView)(this.oTrans.EpiDataViews[“ShipDtl”]));

Conceptually, I want to do something like this:
edvShipDtl.dataView.Table.Select(sd => sd.OrderNum).Distinct();

This doesn’t work but it demonstrates what I’m trying to do.
Is this possible when working with EpiDataViews?

I haven’t done it but you might be able to do this with Linq to DataSet

Filtering with DataView (LINQ to DataSet) - ADO.NET | Microsoft Docs

You can’t use a row filter in a data view to select distinct values (I believe) but you might be able to read the underlying datatable of the dataview, use linq to sort it however you want, and return back the results to a grid or whatever you’re doing

I remember I had to do this once in the past. I looked but couldn’t find that old code. I believe the only way to do this is to convert it to a Data Table using ToTable. There are four signatures for the method, two of them allow a Boolean value for Distinct values when it is converting but you may need to setup Column Names[] for the table .

1 Like

Nice Scott, thanks for adding a picture of the tool you used to understand the object better.