Hi all,
I am having some problems using LINQ to access Distinct records from a Dataset. I have looked around and believe it should be as simple as added
to my LINQ query below, though intellisense doesn't even give that option!
My DataSet has multiple tables, all populated with data. I have a table called DemographicCrit eria which has the fields listed below.
CriteriaID is an autonumber, InputID and ExpressionID are foreign keys from other tables. What I am trying to do is get the distinct DemographicCode s from this table.
I am using the following code:
RawDataDSManage ment is my main class for accessing the DataSet and I know that this is retrieving the data correctly as I have tied a DataGridView to this to check. The rest of it doesn't seem to be working though!
Does anyone have any ideas?
I am having some problems using LINQ to access Distinct records from a Dataset. I have looked around and believe it should be as simple as added
Code:
.Distinct()
My DataSet has multiple tables, all populated with data. I have a table called DemographicCrit eria which has the fields listed below.
- CriteriaID
- DemographicCode
- InputID
- ExpressionID
- Value
CriteriaID is an autonumber, InputID and ExpressionID are foreign keys from other tables. What I am trying to do is get the distinct DemographicCode s from this table.
I am using the following code:
Code:
DataAccess.RawDataDS ds = DataAccess.RawDataDSManagement.RawData; DataTable demoCriteria = ds.Tables["DemographicCriteria"]; IEnumerable<DataRow> query = (from row in demoCriteria.AsEnumerable() select row.Field<string>("DemographicCode")); foreach (DataRow row in query) { Console.WriteLine(row.Field<string>("DemographicCode")); }
Does anyone have any ideas?
Comment