AnsweredAssumed Answered

C# QueryFilter prefixClause "DISTINCT" non-functional

Question asked by mratcliffe_mwwssb on Jul 1, 2019
Latest reply on Jul 1, 2019 by mratcliffe_mwwssb

I'm finding that QueryFilter prefixClause "DISTINCT" is non-functional in the SDK and must use a workaround:


                QueryFilter filter = new QueryFilter
                    //PrefixClause = "DISTINCT",              //DISTINCT does not work in this query. See workaround below.
                    SubFields = "FY",
                    WhereClause = "FY IS NOT NULL AND FY <> '-9' AND FY <> ' '",
                    PostfixClause = "ORDER BY FY"

                using (RowCursor rowCursor = sso_lyr.Search(filter))
                    int fldIndex = rowCursor.FindField("FY");

                    List<string> valuelist = new List<string>();

                    while (rowCursor.MoveNext())
                        string value = rowCursor.Current.GetOriginalValue(fldIndex) as string;

                    IEnumerable<string> distinctvaluelist = valuelist.Select(x => x).Distinct(); //distinct from list b/c DISTINCT prefixclause non-functional above.

                    foreach (string item in distinctvaluelist)
                        Invoke(new MethodInvoker(delegate { Sso_combo.Items.Add(item); }));

This is okay for very short lists of values, but not for 100,000 records; which is the requirement.


Has anyone else encountered this?  I'm using documentation from this source:

Word find: "distinct" on the page...