开发者

Using an SPMetal entity class

开发者 https://www.devze.com 2023-01-28 13:10 出处:网络
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?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号