简体   繁体   中英

search sharepoint list column item having same value

Suppose i have a sharepoint list. Please find below details

Listname="NameData"


Name        ModifiedDate  Place

keshav      19/12/2015    A
madhav      19/11/2015    B
keshav      19/10/2015    C
madhav      19/10/2015    D
Ram         19/10/2015    E

I just wants to get all column values like Name,Modified etc if

Name is duplicate like keshav in name column then it should fetch only those row values in which keshav modified date is latest for example in above Case name column keshav has duplicate value then SPQuery should featch column value as ( Name:keshav,Modified:19/12/2015,Place:A ) as it has latest modified date. If there is no duplicate column value then it should same value. Please provide me Spquery for above case. Thanks

So i was able to answer my own question after one month of struggle.

Please find below code using link query.

   SPList lstICSSDocuments = web.Lists.TryGetList("YourListName");

  List<SPListItem> filtered_List_Item = (from SPListItem item in lstICSSDocuments

                     group item by item["Name"].ToString() into grp

                     select grp.OrderByDescending(g => g["ModifiedDate"]).First()).ToList();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM