This content is archived. See latest version here

Last updated: Nov 16 2015

How it works

By default all public properties on an object are included when indexing it. The simplest way to exclude a property is to annotate it with the JsonIgnore attribute (found in the Newtonsoft.Json namespace).

Example

C#
using Newtonsoft.Json;

public class User
{
    public string Username { get; set; }

    [JsonIgnore]
    public string Password { get; set; }
}

You also can exclude properties, or other previously included fields, by customizing the Client conventions.

C#
//using EPiServer.Find.ClientConventions;

client.Conventions
    .ForInstancesOf<User>()
        .ExcludeField(x => x.Password);

The above code excludes the Password property from instances of the User class as well as instances of classes that inherit the User class.


Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/