mercredi 8 février 2017

Get distinct column values in a set of datarows - Data Table Linq C#

Vote count: 0

I have a simple datatable with four columns and some datarows:

DataTable results = new DataTable();
results.Columns.Add("Wellbore", typeof(string));
results.Columns.Add("Date", typeof(DateTime));
results.Columns.Add("WB", typeof(string));
results.Columns.Add("factor", typeof(double));

I used Linq query to get "list of data rows" when "date=1/1/2017" as:

var AllRowsAtPlanningDate = results.AsEnumerable().Where(x => ((x.Field<DateTime>("Date") == PlanningDate))).ToList();

I would like to get "distinct" values in the "wellbore" column in AllRowsAtPlanningDate . I just want the List<string> and not list<datarows> again.

How to do that? I have been checking some examples here but to no avail.

asked 20 secs ago

Let's block ads! (Why?)



Get distinct column values in a set of datarows - Data Table Linq C#

Aucun commentaire:

Enregistrer un commentaire