使用SPMetal实体类[英] Using an SPMetal entity class

本文是小编为大家收集整理的关于使用SPMetal实体类的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我正在执行以下代码以通过 LINQ 获取有关页面的信息.它工作正常,但我如何转换它并使用 SPMetal 生成的实体命令?

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.SP金属代码

2.SPMetal教程

本文地址:https://www.itbaoku.cn/post/1556932.html

问题描述

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));
    }
}

推荐答案

Use the following links that will be a help for you

1.SP Metal Code

2. SPMetal Tutorial