11

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.

2 Answers 2

13

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!

1
  • that's an amazing answer alex, especially the none = 0 bit :) - thanks
    – johnwinter
    Aug 19, 2014 at 1:38
7

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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