Recent knowledge accumulated during SharePoint Development

Source: Internet
Author: User

1. Delete list items in batch in the operation list

Code

# Batch Delete Region
// Query the list items to be deleted
Query. query = @ "<where> <EQ> <fieldref name = '" + list. Fields ["roleid"]. internalname + @ "'/>
<Value type = 'text'> "+ this. roleid +" </value> </EQ> </where> "; // query Condition
Splistitemcollection items = List. getitems (query );
 
Stringbuilder sbdelete = new stringbuilder ();
Sbdelete. append ("<? XML version = \ "1.0 \" encoding = \ "UTF-8 \"?> <Batch> ");
Foreach (splistitem item in items)
{
Sbdelete. append ("<method> ");
Sbdelete. append ("<setlist scope = \" Request \ ">" + list. ID + "</setlist> ");
Sbdelete. append ("<setvar name = \" ID \ ">" + convert. tostring (item. ID) + "</setvar> ");
Sbdelete. append ("<setvar name = \" cmd \ "> Delete </setvar> ");
Sbdelete. append ("</method> ");
}
Sbdelete. append ("</batch> ");
// Delete operation
Sweb. processbatchdata (sbdelete. tostring ());

# Region comments Delete list items cyclically
// For (INT I = 0; I <items. Count; I ++)
//{
/// AA + = items [I] ["moduleid"]. tostring () + "<br> ";
//// Items [I]. Delete ();
// Items [I]. De ();
//}
# Endregion

# Endregion

 

2. Add list items cyclically

  

Code

# Batch add region
String strmoduleid = this.txt _ moduleid. value. Trim ();
If (! Strmoduleid. Equals (""))
{
Splistitem slistitem = NULL;
String [] moduleidlist = strmoduleid. Split (',');
Foreach (string moduleid in moduleidlist)
{
Slistitem = List. Items. Add ();
Slistitem ["AA"] = This. AA;
Slistitem ["BB"] = BB;
Slistitem. Update ();
}
}
# Endregion

 

3. What are the points to be queried by LINQ (Multi-table joint query, in subquery, and filtering Repeated Records)

  

Code

This. personnamecollection = "Xiao Li, Xiao Wang ";
Datatable dtperson = web. Lists ["person"]. Items. getdatatable ();
Datatable dtcustion = web. Lists ["custion"]. Items. getdatatable ();
Datatable dtpersoncustion = web. Lists ["personcustion"]. Items. getdatatable ();
VaR qlist = (from person in dtperson. asenumerable ()
Join personcustion in dtpersoncustion. asenumerable () on person. Field <string> ("personid") equals personcustion. Field <string> ("personid ")
Join custion in dtcustion. asenumerable () on personcustion. Field <string> ("custionid") equals custion. Field <string> ("custioncode ")
Where this. personnamecollection. Contains (person. Field <string> ("title") // implement in subquery
Orderby custion. Field <string> ("custioncode ")
Select New
{
Parentcustionid = personcustion. Field <string> ("custionid"). substring (0, 2 ),
Custionid = personcustion. Field <string> ("custionid "),
Custionname = custion. Field <string> ("title "),
Custionurl = custion. Field <string> ("url ")
}). Distinct (); // and no repeated records are returned.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.