Using an SPMetal entity class
I'm executing the code below to get information开发者_Go百科 about a page via LINQ. It works fine, but how do I convert this and using the entity class generated by the SPMetal command?
Guid siteGuid = SPContext.Current.Site.ID;
using (SPSite site = new SPSite(siteGuid))
{
using (SPWeb web = site.OpenWeb())
{
SPList lespages = web.Lists["Pages"];
var resultat = from SPListItem page
in lespages.Items
where page.ContentType.Name.Equals("PageNews") && page.ModerationInformation.Status.Equals(SPModerationStatusType.Approved)
select page;
foreach (SPListItem r in resultat)
{
contenu += "_ModerationStatus: " + r["_ModerationStatus"] + "<br>";
contenu += "FileLeafRef: " + r["FileLeafRef"] + "<br>";
contenu += "PublishingPageContent: " + r["PublishingPageContent"] + "<br>";
contenu += "ContentType: " + r["ContentType"] + "<br>";
contenu += "Categorie: " + r["Categorie"] + "<br>";
}
PanelResultat.Controls.Add(new LiteralControl(contenu));
}
}
Use the following links that will be a help for you
1.SP Metal Code
2. SPMetal Tutorial
精彩评论