Greetings
I am using Sharepoint 2016 on Prem
I want to Select all columns but apply "group by" only one using LINQ ( retrieve data from Sharepoint list )
Problem : Currently having 2 problems/challenges
Problem 1: I have lookup field which returns id with name like "23;#abcd" , for this I have to split to get Id only ( mention in below code using split(';').
Problem 2: in LINQ query ,I want to select stautus and documentname columns from list not on "group by".
Group by is just for 1 column like we do in sql server like below as
stautus and documentname feilds are not available in group by so unable to select these 2 fields
- select id,stautus ,documentname,comments from abc groupby userFk
My Code:
- oQuery.Query = "<Where><Eq><FieldRef Name='Flag'/><Value Type ='number'>" + 1 + "</Value></Eq></Where> ";
- var resultfoldeDoc11 = (from SPListItem itm in pLis.GetItems(oQuery)
- orderby itm["ID"]
- group itm by new { m_folderID22 = itm["DocumentFolderFk"] } into g
- select new { m_folderId22 = g.Key.m_folderID22.ToString().Split(';'), m_totaldocsfoldercount = g.Count() });
Solution Required:for Both Problem
How can I select multiple columns in select clause with one field in "Groupby " Clause ?
How can I get only ID from Look up field in LINQ
Thanks