SnapObjects ORM

Simple, Powerful, Ultra-Fast ORM for .NET

SnapObjects ORM makes .NET development a snap! It is unbelievably simple yet does not skimp on features. It gives you full control over generated SQL. And it performs practically like ADO.NET.

Benefits

Simple, Minimal Coding

Simple to code advanced functionality, and data access is in models to minimize maintenance effort.

Type-Safe Queries

.NET objects are used as query criteria in a type-safe manner, and testing APIs are provided to verify SQL.

Flexible SQL Generation

SQL generation is controlled through a comprehensive set of model attributes, or code raw SQL if preferred.

Loose Relationships

Relationships are defined while coding (not pre-defined) and only persist for a particular query.

Transaction-Oriented

Queries, updates, and actions can be tracked, and then transaction management is automatically applied.

Ultra-Fast Performance

There is little overhead on top of ADO.NET, and queries, updates, and actions are executed in bulk.

Code Snippets

Generating complex SQL queries is controlled by intuitive attributes applied to the model.

  1. namespace Appeon.SqlModelMapperDemo.Models
  2. {
  3. //Generates the underlying SQL query according to the attributes
  4.     [Top(1000)]
  5.     [SqlParameter("custId"typeof(int))]
  6.     [SqlParameter("stratOrderDate"typeof(DateTime))]
  7.     [SqlParameter("endOrderDate"typeof(DateTime))]
  8.     [Table("SalesOrderHeader",Schema = "Sales")]
  9.     [SqlWhere("(CustomerId = :custId) and (Orderdate Between :stratOrderDate and :endOrderDate)")]
  10.     public class SalesOrder
  11.     {
  12.         [Key]
  13.         [Identity]
  14.         public int SalesOrderID { get; set; }

  15.         [Required]
  16.         public DateTime? OrderDate { get; set; }

  17.         [Required]
  18.         public byte? Status { get; set; }

  19.         [Required]
  20.         public bool? OnlineOrderFlag { get; set; }

  21.         [SqlCompute("(isnull(N'SO'+CONVERT([nvarchar](23),[SalesOrderID]),N'*** ERROR ***'))")]
  22.         public string SalesOrderNumber { get; set; }

  23.         [Required]
  24.         public int? CustomerID { get; set; }

  25.         [SqlCompute("(isnull(([SubTotal]+[TaxAmt])+[Freight],(0)))")]
  26.         public decimal? TotalDue { get; set; }

  27.         public DateTime? ModifiedDate { get; set; }

  28. //Nests a model and applies various attributes
  29.         [JsonIgnore]
  30.         [SetValue("$SalesOrderID""$SalesOrderID", SetValueStrategy.Always)]
  31.         [ModelEmbedded(typeof(SalesOrderDetail), ParamValue = "$SalesOrderID",
  32.             CascadeCreate =true, CascadeDelete = true)]
  33.         public IList<salesorderdetail> OrderDetails { get; set; }
  34.     }
  35. }

Integrated Environment

Develop, manage, and deploy the non-visual C# projects without leaving the IDE. SnapDevelop features comprehensive solution & project management, fully integrates with leading source control systems, supports NuGet packaging and management, and supports container management & deployment.

Code Generation

Automatically generate skeleton code with various built-in code generation tools and templates. Besides directly generating models from a table, the scaffold templates allow you to configure intricate rules or apply customized templates to get the services and controllers that fit your needs.

Rapid Coding

Code C# rapidly and accurately with powerful code completion tools. SnapDevelop lists valid values, members, properties, and methods, and it automatically filters and highlights the best matches as you type. It also lists various parameter information that is required by a method or an attribute generic type parameter.

Integrated Environment

Develop, manage, and deploy the non-visual C# projects without leaving the IDE. SnapDevelop features comprehensive solution & project management, fully integrates with leading source control systems, supports NuGet packaging and management, and supports container management & deployment.

Integrated Environment

Develop, manage, and deploy the non-visual C# projects without leaving the IDE. SnapDevelop features comprehensive solution & project management, fully integrates with leading source control systems, supports NuGet packaging and management, and supports container management & deployment.

Code Generation

Automatically generate skeleton code with various built-in code generation tools and templates. Besides directly generating models from a table, the scaffold templates allow you to configure intricate rules or apply customized templates to get the services and controllers that fit your needs.

Rapid Coding

Code C# rapidly and accurately with powerful code completion tools. SnapDevelop lists valid values, members, properties, and methods, and it automatically filters and highlights the best matches as you type. It also lists various parameter information that is required by a method or an attribute generic type parameter.

Element Not Found.

Integrated Environment

Develop, manage, and deploy the non-visual C# projects without leaving the IDE. SnapDevelop features comprehensive solution & project management, fully integrates with leading source control systems, supports NuGet packaging and management, and supports container management & deployment.

Code Generation

Automatically generate skeleton code with various built-in code generation tools and templates. Besides directly generating models from a table, the scaffold templates allow you to configure intricate rules or apply customized templates to get the services and controllers that fit your needs.

Rapid Coding

Code C# rapidly and accurately with powerful code completion tools. SnapDevelop lists valid values, members, properties, and methods, and it automatically filters and highlights the best matches as you type. It also lists various parameter information that is required by a method or an attribute generic type parameter.

//Tracks various models, raw SQL, and actions _context.SqlModelMapper.TrackCreate(salesOrder) .Track((saveContext) => { //C# code block …… }) //The C# code block will be executed when SaveChanges is called .TrackUpdate(salesPerson) .TrackSqlCUD(rawSql) .SaveChanges() //Executes all tracked items in one transaction and automatically commits or rolls back

Features

Model

The Model maps columns to database tables and contains the related SQL. The SQL of the Model is generated based on various attributes, which gives developers control over the SQL. And the Model can represent complex relationships, such as Master-Detail-Detail through nesting of the Model.

SQLModelMapper

The SQLModelMapper is a transaction-oriented data manipulation component. It provides objects and methods to simplify your database CRUD operations, and it applies automatic transaction management to tracked items. Tracked items can be executed in bulk to boost performance.

Executes queries and loads the result set to a temporary object for further processing or returns the calculated result set.

Plain Load

Executes queries defined in the model and loads result set into a self-generated object.

Aggregate & Scalar Load

Executes the query defined in the model and returns the result set with aggregate or scalar calculation.

SQLExecutor

SQLExecutor is a set of database manipulation interfaces that encapsulate the core components of ADO.NET. With SQLExecutor you can directly execute dynamic SQL statements, perform SQLBuilder object functions, and do model queries.

Execute

Executes a command and returns the number of affected rows.

Query

Executes a query and maps the result.

SQLBuilder

The SQLBuilder constructs SQL statements in a programmatic and database-agnostic way. Specifically, it builds the syntax structure and works together with SnapObjects’ DataContext object to generate database-specific SQL statements.

Validate

Validates the raw SQL string generated for the specified database.