Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

I'd like my core service application to be as efficient as possible so i'm checking and double checking when I create a 'ReadOptions' object that I'm using the correct ReadFlags property.

I see there is a 'none' on the attribute with the api description:

'Read in the default manner'

I'm wondering what that might be?

I was expecting to have something similar to the 'IdAndTitle' that is found in the BaseColumns when getting lists of objects.

share|improve this question

2 Answers 2

up vote 11 down vote accepted

The LoadFlags differs a lot than say the ListBaseColumns enumeration, in that its actually a flag based property and not just a standard enum. While ListBaseColumns allows you to choose only ONE of the options, the LoadFlags lets you add mix and match by choosing one or many of the options.

When you create a new ReadOptions(), the LoadFlags property is set to None by default. This is the minimal amount of data that you will get back with your xml. Any added flag can return additional data if available, or change how data is returned (like the KeywordXlinks). Flags are added on top of the default data that is returned.

This system allows you to do things like... just return webdav info along with the default data...

ReadOptions options = new ReadOptions();
options.LoadFlags = LoadFlags.WebDavUrls;

As well as return webdav AND allowed actions data along with the default data...

ReadOptions options = new ReadOptions();
options.LoadFlags = LoadFlags.WebDavUrls | LoadFlags.IncludeAllowedActions;

If I wanted to get as much information as possible out, I could do something like:

ReadOptions options = new ReadOptions();
options.LoadFlags = LoadFlags.WebDavUrls | LoadFlags.KeywordXlinks | LoadFlags.Expanded | LoadFlags.IncludeAllowedActions | LoadFlags.IncludeDynamicVersionInfo;

Note that because they made the LoadFlags.None with a value of 0, it's technically always selected, even in the above example, as shown with the code (options.LoadFlags & LoadFlags.None) == LoadFlags.None.

Hope that helps!

share|improve this answer
    
that's an amazing answer alex, especially the none = 0 bit :) - thanks –  johnwinter Aug 19 at 1:38

Brilliant response from Alex, to answer your question from another angle though; you can avoid constantly passing a new instance by declaring a number of static instances.

Review the use cases where you're accessing Core Service and what levels of data you're likely to need back. Then classify those data levels for easy access and maintenance. For example:

private static readonly ReadOptions DefaultReadOptions = new ReadOptions { LoadFlags = LoadFlags.None };
private static readonly ReadOptions WebDavReadOptions = new ReadOptions { LoadFlags = LoadFlags.WebDavUrls };
private static readonly ReadOptions ExpandedReadOptions = new ReadOptions { LoadFlags = LoadFlags.Expanded };
private static readonly ReadOptions ALLTHETHINGSReadOptions = new ReadOptions { LoadFlags = LoadFlags.Expanded | LoadFlags.IncludeAllowedActions | LoadFlags.KeywordXlinks | LoadFlags.WebDavUrls };

Then once they have been declared you can use them accordingly:

var schemaFieldsData = ProxyClient.ReadSchemaFields(schemaId, true, ExpandedReadOptions);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.