Tuesday, December 6, 2011





Sharepoint Dispose Check Tool

Check Memory Leakage in your sharepoint Object use the below mwntion tool

Using join with CAML in SharePoint development

The each join is represented by a join element (which is child of Joins element). You can use joins to join multiple lists or use multiple joins to the same list.

Example:

I am going to show you how to use left outer join in CAML query.

The “EmployeeName” is a lookup field on a “Users” list. It looks up to the “ID” field of an “Employees” list. The “Employee” list in turn, has a “CountryName” field that is a lookup field to a “Countries List”. The first Join element assigns ‘employees’ as an alias for the “Employees” list. The second Join element assigns ‘employeeCountries’ as an alias to the “Countries” list. This query will define the join in parallel to the existing lookup relation between the “Employees” and “Countries” lists.

CAML Code:

Joins

Join Type=’LEFT’ ListAlias= ‘employees’

Eq

FieldRef Name=’EmployeeName’ RefType=’Id’

FieldRef List=’employees’ Name=’ID’

Eq

Join

Join Type=’LEFT’ ListAlias= ‘employeeCountries’

Eq

FieldRef List=’employees’ Name= ‘CountryName’ RefType=’Id’

FieldRef List=’ employeeCountries’ Name=’ID’

Eq

Join

Joins

Check User Exist in Share point Groups

string CurrentSiteURL = "http://gildevbox3:10866/";

string currentUser="user1";

try

{

SPSecurity.RunWithElevatedPrivileges(delegate()

{

using (SPSite site = new SPSite(CurrentSiteURL))

{

using (SPWeb web = site.RootWeb)

{

SPUser user = web.EnsureUser(currentUser);

foreach(SPGroup group in web.Groups)

{

if (group.Name.ToLower() == "Study Owner".ToLower())

{

foreach (SPUser u in group.Users)

{

if (u.Name.ToLower() == user.Name.ToLower())

{

}

r

}

}

}

}

}

});

}

catch

{

}