"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\SPMetal" /web:http://admin2-pc:54321 /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();
Comments
Post a Comment