Skip to main content
All docs
V24.2
.NET 8.0+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

XAF0020: Avoid applying NonPersistentAttribute to properties without a public setter

Severity: Warning

The NonPersistentAttribute is redundant for read-only properties (non-public or missing setters). Apply the attribute only to writeable properties if you do not want their values to persist in a data store.

#Examples

#Invalid Code

[NonPersistent]
public Topic Topic {
     get { return fTopic; }
}
Topic fTopic;

// OR

[NonPersistent]
public Topic Topic {
    get { return fTopic; }
    private set { SetPropertyValue(nameof(Topic), ref fTopic, value); }
}
Topic fTopic;

#Valid Code

public Topic Topic {
    get { return fTopic; }
}
Topic fTopic;

// OR

public Topic Topic {
    get { return fTopic; }
    private set { SetPropertyValue(nameof(Topic), ref fTopic, value); }
}

// OR

[NonPersistent]
public AnyType Topic {
    get { return fTopic; }
    set { SetPropertyValue(nameof(Topic), ref fTopic, value); }
}
AnyType fTopic;