/// <summary> /// generate a list of CensorCodes /// This is done as a separate method since Values can could contain other VariableValue Types /// /// </summary> /// <param name="ds">ValuesDataSet with the values used in the timeSeries</param> /// <param name="valuesWhereClause"></param> /// <returns></returns> public static IEnumerable <CensorCodeType> datasetCensorCodes(ValuesDataSet ds, string valuesWhereClause) { /* generate a list * create a distinct DataSet * - new data view * - set filter (no nulls) * - use toTable with unique to get unique list * foreach to generate qualifiers * */ string COLUMN = "CensorCode"; string TABLENAME = "CensorCodeCV"; DataView view = new DataView(ds.DataValues); view.RowFilter = valuesWhereClause; DataTable ids = view.ToTable(TABLENAME, true, new string[] { COLUMN }); foreach (DataRow r in ids.Rows) { //Object aId = r[COLUMN]; if (r[COLUMN] == DBNull.Value) { continue; } string aId = (string)r[COLUMN]; // edit here ValuesDataSet.CensorCodeCVRow codeCvRow = ds.CensorCodeCV.FindByTerm(aId); if (codeCvRow != null) { CensorCodeType t = new CensorCodeType(); t.censorCode = codeCvRow.Term; if (!codeCvRow.IsDefinitionNull() && !String.IsNullOrEmpty(codeCvRow.Definition)) { t.censorCodeDescription = codeCvRow.Definition; } yield return(t); } } //foreach (ValuesDataSet.CensorCodeCVRow r in ds.CensorCodeCV.Rows) //{ // CensorCodeType t = new CensorCodeType(); // t.censorCode = r.Term; // if (!r.IsDefinitionNull() && !String.IsNullOrEmpty(r.Definition)) // { // t.censorCodeDescription = r.Definition; // } // yield return t; //} }
/// <summary> /// generate a list of CensorCodes /// This is done as a separate method since Values can could contain other VariableValue Types /// /// </summary> /// <param name="ds">ValuesDataSet with the values used in the timeSeries</param> /// <param name="valuesWhereClause"></param> /// <returns></returns> public static IEnumerable<CensorCodeType> datasetCensorCodes(ValuesDataSet ds, string valuesWhereClause) { /* generate a list * create a distinct DataSet * - new data view * - set filter (no nulls) * - use toTable with unique to get unique list * foreach to generate qualifiers * */ string COLUMN = "CensorCode"; string TABLENAME = "CensorCodeCV"; DataView view = new DataView(ds.DataValues); view.RowFilter = valuesWhereClause; DataTable ids = view.ToTable(TABLENAME, true, new string[] { COLUMN }); foreach (DataRow r in ids.Rows) { //Object aId = r[COLUMN]; if (r[COLUMN] == DBNull.Value) { continue; } string aId = (string)r[COLUMN]; // edit here ValuesDataSet.CensorCodeCVRow codeCvRow = ds.CensorCodeCV.FindByTerm(aId); if (codeCvRow != null) { CensorCodeType t = new CensorCodeType(); t.censorCode = codeCvRow.Term; if (!codeCvRow.IsDefinitionNull() && !String.IsNullOrEmpty(codeCvRow.Definition)) { t.censorCodeDescription = codeCvRow.Definition; } yield return t; } } //foreach (ValuesDataSet.CensorCodeCVRow r in ds.CensorCodeCV.Rows) //{ // CensorCodeType t = new CensorCodeType(); // t.censorCode = r.Term; // if (!r.IsDefinitionNull() && !String.IsNullOrEmpty(r.Definition)) // { // t.censorCodeDescription = r.Definition; // } // yield return t; //} }