本文介绍了使用SPMetal实体类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

2. SPMetal教程

这篇关于使用SPMetal实体类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-25 10:16