You are viewing limited content. For full access, please sign in.

Question

Question

SDK RA C# - Retrieving entries and their respective fields and values is taking too long

asked on November 13, 2014 Show version history

I have a piece of code that gets all the entries for a given template and a couple of given conditions. I successfully get the entries and their metadata (id, name, owner, etc..), after getting those entries i need to get all the fields and its values for each and every one of them, i accomplish this by calling Entry.TryGetEntryInfo(id, session).
However this is taking too long, like 4-5 minutes for 2,000 entries.

Is there a way to get all the entries, their metadata and all their fields and values ALL AT ONCE for a given template without having to use Entry.TryGetEntryInfo or is there a better way (performance wise) to accomplish this?.

Here is my code:

Session mySess = null;
            try
            {
                mySess = LFSessionFactory.CreateDefaultSession();
                Search lfSearch = new Search(mySess);

                lfSearch.Command = "{[EISD -- Business / Vendor Invoices]:[Invoice Date]>=\"11/08/2013\",[Invoice Date]<=\"11/10/2014\"}";
                lfSearch.Run();

                SearchListingSettings searchSettings = new SearchListingSettings();
                searchSettings.SortDirection = SortDirection.Ascending;
                SearchResultListing results = lfSearch.GetResultListing(searchSettings);

                for (int i = 1; i < results.RowCount; i++)
                {
                    int entryId = (int)results.GetDatum(i, SystemColumn.Id);
                    // this is what is taking too long
                    EntryInfo currentEntry = Entry.TryGetEntryInfo(entryId, mySess);
                    Console.WriteLine(currentEntry.Name);
                }
                Console.WriteLine(results.RowsCount);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                LFSessionFactory.CloseSession(mySess);
            }

 

0 0

Replies

replied on November 13, 2014

Armando,

Have you tried the GetEntryInfo method instead of the TryGetEntryInfo?  So the For/Next block would look like this...

14                   for (int i = 1; i < results.RowCount; i++)
15	                {
16	                    int entryId = (int)results.GetDatum(i, SystemColumn.Id);
17	                    // this is what is taking too long
18	                    EntryInfo currentEntry = Entry.GetEntryInfo(entryId, mySess);
19	                    Console.WriteLine(currentEntry.Name);
20	                }

Once you have a reference to the Entry you can then use the Entry.GetFieldValues method to obtain a FieldValueCollection which contains all of the metadata assigned to the template.

FYI - I don't see the TryGetEntryInfo method listed in the SDK documentation and I believe I have always used the GetEntryInfo method when using RA. 

The other option, probably not endorsed by LF, is to go straight to the SQL tables.

0 0
replied on November 14, 2014 Show version history

Yes i have tried using Entry.GetEntryInfo, it takes the same amount of time to process the search. Thanks, will check the SQL option.

0 0
replied on November 14, 2014

You can bypass the Entry.GetEntryInfo call by calling the static method

FieldValueCollection GetFieldValues(int entryId, Session session)

to retrieve the field values without having to call Entry.GetEntryInfo.

 

 

0 0
replied on November 14, 2014

Thank you, didn't know that.
However it still takes a lot of time to process the search.

0 0
replied on November 14, 2014

If you know the template ahead of time, you can add each field to the entry listing, like this:

searchSettings.AddColumn("Field1");

And retrieve the fields from the listing with GetDataum(rowNumber, fieldName);

The drawback is that multivalue fields only return the first value when retrieved from the entry listing.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.