I'm working with visual studio 2010 and I have this list:

    List<SPFieldUserValue> directeursDelegues = (from SPListItem agence in webSite.Lists[agenceGuid].Items
                                         select (SPFieldUserValue)delegueField.GetFieldValue(agence["Directeur_x0020_D_x00e9_l_x00e9_"].ToString())

I'm trying to get distinct values from this list. But it doesn't seem to work. Do you know how to do it?


I've found the answer:

    List<SPFieldUserValue> directeursDelegues = (from SPListItem agence in webSite.Lists[agenceGuid].Items//agence list
                                                                             select (SPFieldUserValue)delegueField.GetFieldValue(agence["Directeur_x0020_D_x00e9_l_x00e9_"].ToString())
                                                                             ).GroupBy(x => x.User.ID).Select(group => group.First()).ToList();

I don't know if it is the best way but it works fine.

  • If its working fine, go for this.
    – Aanchal
    Jun 23, 2014 at 14:10

1 Answer 1


CAML query schema for Sharepoint doesn't contain distinct still, so there is not Distinct operation in CAML Queries.

However you may group results in CAML (using GroupBy element) - it will produce groups for distinct values of the field by which you will perform grouping. So this is only otption for you to get uniques values.

CAML query on Sharepoint List without duplicates


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.