---
title: Preference
summary: API reference for Preference.
status: draft
owner: <owner>
last_reviewed: 2026-07-23
library: SAIF.Framework.Preferences
reference_type: package
---

# Preference

`Preference` is a plain data-transfer object representing one saved preference record — the application name, optional page name, preference ID, and deserialized key/value item dictionary. It carries no data-access behavior of its own; rows are populated into `Preference` instances by `PreferenceData.GetPreferencesForUser`.

## Purpose
- Represent a single row retrieved from [USER_PREFERENCE](../../database-tables.md#user_preference) as a strongly-typed object for consumption by host applications.

## Context
- Namespace: `SAIF.Framework.Preferences`
- Assembly/package: `SAIF.Framework.Preferences`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `PreferenceId` | `public Decimal PreferenceId` | Holds the row's `USER_PREFERENCE_SEQ_NUM` primary-key value. |
| `ApplicationName` | `public string ApplicationName` | Holds the application name (`APP_NAME`) that owns the preference. |
| `Pagename` | `public string Pagename` | Holds the optional page name (`PAGE_NAME`) scoping the preference. |
| `PreferenceItems` | `public Dictionary<string, string> PreferenceItems` | Holds the deserialized key/value pairs from the stored `PREFERENCE_TEXT` JSON payload. |
| `Preference()` | `public Preference()` | Parameterless constructor; no additional initialization logic. |

## Behavioral notes
- `PreferenceItems` is populated only by `PreferenceData.GetPreferencesForUser`, which deserializes `PREFERENCE_TEXT` via `JavaScriptSerializer` when the stored text is non-empty; otherwise the dictionary is left in its default state.*
- This type is used exclusively as an output/read model — no method on `Preference` itself performs data access.*

## Constraints and usage notes
- Fields are public and mutable; there is no encapsulation or validation logic on this type.
- Callers reading preferences for a single app/page (via `PreferenceData.GetPreferences`) receive a raw `string` rather than a `Preference` instance; `Preference` objects are only produced by `GetPreferencesForUser`.

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts.

## Sources
- SAIF.Framework.Preferences\Preference.cs
