SujaySarma.Data.Core
10.0.0
dotnet add package SujaySarma.Data.Core --version 10.0.0
NuGet\Install-Package SujaySarma.Data.Core -Version 10.0.0
<PackageReference Include="SujaySarma.Data.Core" Version="10.0.0" />
<PackageVersion Include="SujaySarma.Data.Core" Version="10.0.0" />
<PackageReference Include="SujaySarma.Data.Core" />
paket add SujaySarma.Data.Core --version 10.0.0
#r "nuget: SujaySarma.Data.Core, 10.0.0"
#:package SujaySarma.Data.Core@10.0.0
#addin nuget:?package=SujaySarma.Data.Core&version=10.0.0
#tool nuget:?package=SujaySarma.Data.Core&version=10.0.0
SujaySarma.Data.Core
Core reflection, attribute discovery, validation, data conversion, and ORM services for the SujaySarma.Data. library ecosystem.*
Overview
SujaySarma.Data.Core is the foundational library for all SujaySarma.Data.* libraries. It provides a comprehensive set of attributes, reflection utilities, and ORM infrastructure that enable powerful object-relational mapping capabilities across various data backends including SQL Server, Azure Storage Tables, and flat files.
This library focuses on performance, stability, and API consistency as its core principles.
Installation
$ dotnet add package SujaySarma.Data.Core
NuGet Package: SujaySarma.Data.Core
Current Version: 10.0.0.0
Target Frameworks: .NET 6.0, .NET 8.0, .NET 10.0
Features
- Attribute-based ORM System – Decorate your business entities with powerful attributes to enable automatic persistence
- Type Discovery & Caching – Fast metadata discovery with intelligent caching for performance
- Data Conversion Utilities – Extensive extension methods for type conversions, date/time handling, and data coercion
- Batch Transaction Support – Efficient batch processing for bulk operations
- Dirty State Tracking – Automatic change tracking for entities
- Soft Delete Support – Built-in support for soft-delete patterns
- System-Populated Fields – Automatic value generation for timestamps, GUIDs, and identity fields
Quick Start
1. Decorate Your Entity
using SujaySarma.Data.Core.Attributes;
[PersistenceContainer(Name = "Users")]
public class User {
[PersistenceContainerMember(Name = "Id")]
[OrmPopulatedGuidField]
public Guid Id { get; set; }
[PersistenceContainerMember(Name = "Username")]
public string Username { get; set; }
[PersistenceContainerMember(Name = "Email")]
public string Email { get; set; }
[PersistenceContainerMember(Name = "CreatedDate")]
[OrmPopulatedTimestampField]
public DateTime CreatedDate { get; set; }
[DirtyStateField]
public bool IsDirty { get; set; }
}
2. Discover Type Metadata
using SujaySarma.Data.Core;
PersistenceContainerInfo containerInfo = TypeDiscoveryFactory.Resolve<User>();
// Access metadata about the User type, its members, and attributes
API Reference
Attributes
Container-Level Attributes
Attributes applied to classes, structs, or records:
| Attribute | Type | Purpose |
|---|---|---|
IPersistenceContainer |
Interface | Marks an entity as ORM-enabled with metadata about backend storage |
PersistenceContainer |
Implementation | Concrete implementation of IPersistenceContainer |
Member-Level Attributes
Attributes applied to properties or fields:
| Attribute | Type | Purpose |
|---|---|---|
IOrmField |
Interface | Base interface for all member attributes |
IPersistenceContainerMember |
Interface | Marks a member for hydration/dehydration with backend metadata |
PersistenceContainerMember |
Implementation | Concrete implementation of IPersistenceContainerMember |
ISystemPopulatedField |
Interface | Indicates the value is automatically supplied by the system |
IBackendSystemPopulatedField |
Interface | Value supplied by the backend (e.g., IDENTITY columns) |
IOrmPopulatedField |
Interface | Value supplied by the ORM (e.g., auto-generated GUIDs) |
OrmPopulatedGuidField |
Implementation | Automatically generates new Guid values |
OrmPopulatedTimestampField |
Implementation | Automatically generates DateTime timestamps |
IDirtyStateField |
Interface | Enables dirty state tracking for the entity |
DirtyStateField |
Implementation | Concrete implementation of IDirtyStateField |
ISoftDeleteRecords |
Interface | Enables soft-delete pattern support |
Note:
OrmPopulatedGuidField,OrmPopulatedTimestampField, andDirtyStateFieldare independent attributes that don't extendPersistenceContainerMember, allowing ORM libraries to handle them separately.
Core Classes
TypeDiscoveryFactory
The primary entry point for metadata discovery. Analyzes types decorated with IPersistenceContainer and returns comprehensive metadata.
Key Features:
- Discovers entity metadata from attributes
- Caches results for performance
- Validates attribute configurations
Usage:
PersistenceContainerInfo info = TypeDiscoveryFactory.Resolve<MyEntity>();
// OR...
PersistenceContainerInfo info = TypeDiscoveryFactory.Resolve(typeof(MyEntity)); PersistenceContainerInfo info = TypeDiscoveryFactory.Resolve(myEntityInstance);
BatchCollection
Manages batch transactions for bulk operations with configurable batch sizes.
Usage:
BatchCollection<User> batches = new BatchCollection<User>(users, batchSize: 100);
foreach ((Batch<User> batch, int batchIndex) in batches)
{
// Process each batch
}
Result
Provides a consistent structure for returning transaction results.
Extension Methods
The ReflectionUtilities namespace contains approximately 100 extension methods for:
- Date/Time Conversions – Convert between
DateTime,DateTimeOffset, and various formats - Type Conversions & Coercion – Safe type casting and conversion utilities
- String Manipulation – Common string operations for data processing
- Collection Operations – LINQ-style extensions for data collections
- Validation Helpers – Check nullability, emptiness, and validity
All extension methods are fully documented with XML comments.
Advanced Usage
Dirty State Tracking
[PersistenceContainer(Name = "Products")]
public class Product
{
[PersistenceContainerMember(Name = "Id")]
public int Id { get; set; }
[PersistenceContainerMember(Name = "Name")]
public string Name { get; set; }
[DirtyStateField]
public bool IsDirty { get; set; }
// The ORM can check IsDirty to determine if INSERT/UPDATE/DELETE is needed
}
Soft Delete Support
[PersistenceContainer(Name = "Orders")]
[ISoftDeleteRecords(DeletedFieldName = "IsDeleted")]
public class Order
{
[PersistenceContainerMember(Name = "Id")]
public int Id { get; set; }
[PersistenceContainerMember(Name = "IsDeleted")]
public bool IsDeleted { get; set; }
// Soft-deleted records are excluded from queries unless explicitly requested
}
Architecture
SujaySarma.Data.Core serves as the foundation for specialized data access libraries:
- SujaySarma.Data.SqlServer – SQL Server ORM with full T-SQL feature parity
- SujaySarma.Data.Files.TokenLimitedFiles – High-performance CSV/flat-file parser (84K records in <200ms)
Version History
| Version | Release Date | Notes |
|---|---|---|
10.0.0.0 |
Nov 28, 2025 | Complete rewrite – NOT backwards compatible |
Requirements
- .NET 6.0 or higher
- C# 10.0 or higher (nullable reference types enabled)
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request with clear descriptions
For issues, feature requests, or feedback, please create an issue on GitHub.
License
This library is licensed under the MIT License. Copyright (c) 2025 and beyond, Sujay V. Sarma. All rights reserved.
Author
Sujay V. Sarma
- GitHub: @sujayvsarma
- Repository: SujaySarma.Data
Important Notes
⚠️ Internal Members: This library contains public members intended only for use by
SujaySarma.Data.*implementation libraries. These are part of the internal implementation and should not be used directly by consumers. They are subject to change without notice.
📊 Performance Focus: As the foundational layer, this library prioritizes performance, stability, and API consistency above all else.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (6)
Showing the top 5 NuGet packages that depend on SujaySarma.Data.Core:
| Package | Downloads |
|---|---|
|
SujaySarma.Data.Azure.Tables
(Azure Storage Tables, Azure Development Storage, Azurite and CosmosDB compatible). This library provides data access and management capabilities for Azure Storage Tables. |
|
|
SujaySarma.Data.SqlServer
Use this SDK to avoid having to use Entity Framework (EF) and simplify your time to code complete. This library is built along the familiar lines of my Azure Tables package. Use the attributes from the 'SujaySarma.Data.SqlServer.Attributes' namespace to decorate your business object classes/records/structs and their properties and fields. The 'SqlTableContext' is your starting point for firing any DML or query operations. To debug query generation, use the methods in the 'SQLScriptGenerator' class -- the outputs of these functions are used in the DML operations. |
|
|
SujaySarma.Data.Files.TokenLimitedFiles
This library makes it easy to work with token-limited flatfiles, like .CSV, .TSV, .TXT. |
|
|
SujaySarma.Data.TokenLimitedFiles
This library provides mechanisms to read from and write data to token delimited files -- such as comma, semi-colon, space, tab, etc seperated flat text files. These files may have file extensions of .csv or .txt. In addition to disk files, the library also supports reading from and writing to streams (eg: Http file download streams, Uploaded files from web-based forms, etc). This library is highly performance optimised. My benchmark: Parse and correctly load a flat text file with 20,000 records in less than 1 second. This file contains a mix of good data, erroroneous data, quoted, unquoted, badly quoted, wrongly quoted, etc. that interprets the RFC specification in both letter and spirit. Typically, this library surpasses this metric by finishing in less than 300ms. |
|
|
SujaySarma.Data.WindowsRegistry
Use this SDK to simplify your use of the Windows Registry to store and retrieve configuration, state and other information. We use the same practices as in my other SujaySarma.Data.* packages to provide attribute-decoration powered ODM (object-data mapping) services. Use the attributes provided in the library to decorate your .NET classes, structures or records to seamlessly pull or push data between your application(s) and the Windows Registry. |
GitHub repositories
This package is not used by any popular GitHub repositories.
[10.0.0.0] - Complete rewrite of the library! This version is NOT backwards compatible with previous versions.