回收站查询,linq对对象集合的使用

 public static void DeleteRecycleBinContent(SPRecycleBinOrderBy orderBy, bool ascending, string siteUrl)
{
    

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteUrl))
                {
                    SPRecycleBinQuery query = new SPRecycleBinQuery();
                    query.ItemCollectionPosition = SPRecycleBinItemCollectionPosition.FirstPage;
                    query.ItemState = SPRecycleBinItemState.FirstStageRecycleBin;
                    query.RowLimit = 500;
                    query.IsAscending = ascending;
                    query.OrderBy = orderBy;

                    SPRecycleBinItemCollection binItems = site.GetRecycleBinItems(query);

                    var filteredItems = from i in binItems.OfType<SPRecycleBinItem>()
                                        where i.ItemType == SPRecycleBinItemType.File && i.Title.Contains("YYY") && i.DeletedBy.LoginName == "basesmcdev2\\steve.curran"
                                        select i;


                    if (filteredItems != null & filteredItems.Count() > 0)
                        filteredItems.First().Delete();
                     
                }
            });

}

转自http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/a2fe21f2-39bc-4c9d-91f4-ed7910499336

 

posted @ 2010-01-14 11:53  邑尘  阅读(296)  评论(0编辑  收藏  举报