Using an SPMetal entity class

风格不统一 提交于 2019-12-24 10:40:03

问题


I'm executing the code below to get information 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));
    }
}

回答1:


Use the following links that will be a help for you

1.SP Metal Code

2. SPMetal Tutorial



来源:https://stackoverflow.com/questions/4324284/using-an-spmetal-entity-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!