---
title: SAIF.Framework.Preferences overview
summary: High-level purpose, scope, and responsibilities for this library.
status: draft
owner: <owner>
last_reviewed: 2026-07-23
library: SAIF.Framework.Preferences
reference_type: package
---

# SAIF.Framework.Preferences overview

> **Documentation context:** Packaged Component (NuGet)

`SAIF.Framework.Preferences` is a small, self-contained data-access library that persists per-user application/page preference blobs in a single Oracle table, `USER_PREFERENCE`. It consists of exactly two classes — the `Preference` DTO and the `PreferenceData` data-access class — and issues inline SQL directly rather than using the framework's standard business-object (`clsBusinessBase`/`IBusinessCriteria`) pattern.

## Purpose
- Provide a data-access surface for reading a single preference blob (`GetPreferences`), reading all preferences for a user (`GetPreferencesForUser`), and upserting/deleting a preference (`SavePreferences`).
- Represent one saved preference record as a simple DTO (`Preference`), carrying application name, page name, preference ID, and a deserialized key/value item dictionary.
- Normalize and scope preference identity by application name, user ID (lower-cased), and optional page name.
- Serialize/deserialize the stored preference payload as JSON (`PREFERENCE_TEXT`) using `JavaScriptSerializer`.
- Consumed by host applications, which supply their own `IDataPortalInfo` execution context; this library resolves no configuration or connection settings itself.

## Responsibilities
- Read a single preference blob scoped by application, user, and optional page (`GetPreferences`).
- Read all preferences for a given user across all applications/pages (`GetPreferencesForUser`).
- Upsert or delete a preference row via a single entry point (`SavePreferences`), which dispatches to internal insert, update, or delete logic based on existing-row state and whether the supplied preference text is empty.

## Key components
- `Preference`: Plain data-transfer object representing one saved preference record (`PreferenceId`, `ApplicationName`, `Pagename`, `PreferenceItems`).
- `PreferenceData`: The sole data-access class; reads and writes `USER_PREFERENCE` rows via inline Oracle SQL executed through `SqlHelper.ResultSetQuery` and `SqlHelper.ScalarQuery<T>`.

## Related documentation
- [Index](index.md)
- [Architecture](architecture.md)
- [Dependencies](dependencies.md)
- [Operations and processes](operations-processes.md)
- [Business rules](business-rules.md)
- [Configuration](configuration.md)
- [Database tables](database-tables.md)
- [SQL catalog](sql/index.md)
- [API reference](api/index.md)

## Sources
- `SAIF.Framework.Preferences\Preference.cs`
- `SAIF.Framework.Preferences\PreferenceData.cs`
- `SAIF.Framework.Preferences\SAIF.Framework.Preferences.csproj`
