SPMetal – SharePoint 2010 LINQ Sample in Visual Webpart


SPMetal – SharePoint 2010 LINQ Sample in Visual Webpart

“C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\SPMetal” /web:http://admin2-pc:10 /namespace:SPwithLinq.VisualWebPart1 /code:SPMetal.cs /language:csharp  /parameters:SPMetal.xml
Add Reference : Microsoft.SharePoint.Linq
Namespace:
using Microsoft.SharePoint; using Microsoft.SharePoint.Linq; using System.Linq;
SPMetalDataContext oDat = new SPMetalDataContext(SPContext.Current.Site.Url);             var Employees = from Emp in oDat.Employee                             orderby Emp.Name                             where (Emp.Department == “IT” || Emp.Department ==”HR”)                             select new { Emp.Name, Emp.Department, Emp.Designation };
GridView1.DataSource = Employees.AsEnumerable();             GridView1.DataBind();

Create Silverlight Graphs with SharePoint 2010 Data by Using LINQ
Advertisements

About sharepointsriram

9+ Yrs of IT experience
This entry was posted in Sharepoint 2010 LINQ. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s