Howto: Use lambda expression in SharePoint – Working with SPWeb
English
Before you continue reading this post, I hope you have read the basic task to start using lambda expression in SOM here.
A. Find any Event list in site.
SPWeb spWeb = SPContext.Current.Web
var lists = spWeb.Lists.OfType
().Where(
l => l.BaseTemplate == SPListTemplateType.Events);
foreach (SPList list in lists)
{
Console.WriteLine(“{0} {1}”, list.BaseTemplate.ToString(), list.Title);}
B. Find any list based on custom list definition with Type=20080
SPWeb spWeb = SPContext.Current.Web
var lists = spWeb.Lists.OfType
().Where(
l => (int) l.BaseTemplate == 20080);
foreach (SPList list in lists)
{
Console.WriteLine(“{0} {1}”, list.BaseTemplate.ToString(), list.Title);}
C. Find any “Daily” alert in the site
SPWeb spWeb = SPContext.Current.Web
var alerts = spWeb.Alerts.OfType
().Where(
a => a.AlertFrequency == SPAlertFrequency.Daily);foreach (SPAler alert in alerts)
{
// Do something with alert}
D. Find any user which are Domain group
SPWeb spWeb = SPContext.Current.Web
var users = spWeb.SiteUsers.OfType
().Where(
u => u.IsDomainGroup );foreach (SPUser user in users)
{
// Do something with alert}