Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5969161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:11:28+00:00 2026-05-22T20:11:28+00:00

I am using C# code and Tridion(CMS) classes to fetch data from Tridion, below

  • 0

I am using C# code and Tridion(CMS) classes to fetch data from Tridion, below is the code to get all the publications List from Tridion.

protected void btnPublishPublicationList_Click(object sender, EventArgs e)
    {
        try
        {
            PublicationBL pubBL = new PublicationBL();
            TridionCollection<Publication> pubAllList = pubBL.getAllPublicationList();
            List<PublicationsBO> pubBos = new List<PublicationsBO>();

            foreach (Publication pub in pubAllList)
            {
                if ((pub.Title.StartsWith("07"))||(pub.Title.StartsWith("08")))
                {
                    PublicationsBO pubBO = new PublicationsBO();
                    pubBO.publicationID = pub.ID;
                    pubBO.publicationName = pub.Title;
                    pubBos.Add(pubBO);
                }
            }

            pubBL.createPublicationListXML(pubBos);          
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }

In above code on the button click, I am using .net code and using Tridion class to get all the publications List as below:

TridionCollection<Publication> pubAllList = pubBL.getAllPublicationList();

I am getting my all the publications list very fast from the Tridion, however when I am going for foreach loop as below my process gets stuck and it takes lots of time to do this.

foreach (Publication pub in pubAllList)
            {
                if ((pub.Title.StartsWith("07"))||(pub.Title.StartsWith("08")))
                {
                    PublicationsBO pubBO = new PublicationsBO();
                    pubBO.publicationID = pub.ID;
                    pubBO.publicationName = pub.Title;
                    pubBos.Add(pubBO);
                }
            }

After debugging I found that when debugger comes to foreach (Publication pub in pubAllList) it is taking lots of time. I think while making the Publication class object is taking time and it is Tridion class.

Please suggest any other way to do this or suggest what is wrong in above code.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:11:29+00:00Added an answer on May 22, 2026 at 8:11 pm

    according to this which I think is the developers site… it looks like getAllPublicationList is using some sort of lazy loading so even though you have the collection you don’t really have the items in it.

    It appears that you can set filters on their collection rather than after the fact so that it will only load the records you are interested in.

    to clarify, lazy loading means that when the collection is returned the data needed to populate the items in it are not yet laded. It isn’t until you access the item in the collection that the data (e.g. by creating a Publication item) for that item is actually loaded. The purpose for using a lazy collection is to allow filtering on the collection so that unnecessary expensive loads can be avoided.

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the code below, I am returning an nvarchar field from MS SQL 2005
I am using the code snippet below, however it's not working quite as I
I've started using Code Contracts in all new code I'm writing, such as in
I am using code below. How Do add error checking. If anything is error,
I'm using code similar to whats below with the exception that the thread is
I'm using code similar to below: var image = new Image(); image.src = http://youtube.com/favicon.ico;
I am using code below, the session variables are declarated in Common class and
I have swf file, im using code below to display it on my website:
I'm using code that I found on the CodeProject.com for a low-level keyboard hook
I've recently started using code coverage tools (particularily Emma and EclEmma), and I really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.