From Wikipedia, the free encyclopedia
Jump to: navigation, search
Developer(s) Xtensive LLC
Stable release
4.4.1 / December 19, 2011 (2011-12-19)
Written in C#
Operating system Microsoft Windows
Platform .NET 3.5, 4.0
Type Object-relational mapping
License Proprietary

DataObjects.NET is a persistence and object-relational mapping framework for the Microsoft .NET Framework. It allows the developer to define the business logic (persistent objects) directly in one of the .NET languages like C#. The persistent objects can be retrieved by LINQ queries. Persistent data can be stored in SQL Servers or in even simpler DBMS which only provide simple indexing operations. In contrast to many other ORM frameworks the database model is generated and maintained automatically.

Persistence and mapping[edit]

Application development with DataObjects.NET follows the domain-driven design principle. The model (business logic) can be declared directly and completely in source code using attributes. Even the migration and update logic from older model versions is declared this way. Because the complete model is expressed in standard .NET source code DataObjects.NET integrates seamlessly in revision control and visual class design tools.

This code sample declares a persistent Person class with a Name field:

public class Person: Entity
  [Field, Key]
  public Guid Id { get; private set; }
  [Field(Length = 100)]
  public string Name { get; set; }

Unlike NHibernate does not need a declared mapping to some kind of database. Instead it generates the needed tables and columns on the database itself. To do this it uses this metadata (the model) to create and modify the database schema on the underlying SQL Server or other DBMS. This reduces the development time and maintenance effort. It is also possible to use existing (legacy) data in a heterogeneous manner.

The persistent classes can be used like every other class to create and modify persistent objects with the new operator and by assigning same data to properties.

using (var session = Domain.OpenSession()) {
  using (var transactionScope = session.OpenTransaction()) {
    var person= new Person() { Name = "John Doe" };
    person.Name = "Jane Doe";

Due to the use of session scopes and transaction scopes these transactional modifications are ACID. Because these persistent classes do not use methods like session.Save(person) some other mechanism must come into play to store the data. DataObjects.NET uses aspect-oriented programming to inject the load/save mechanisms in the classes. The PostSharp framework is used to inject the policies for persistence.

The persistence layer is completely transparent and does performance acceleration like lazy loading and caching behind the scenes.

LINQ queries[edit]

Unlike POCO the DataObjects.NET Entities are queryable in a relational manner. This can be done with a low level API - the so-called ‘Record Set Engine Queries’. And it can be done high level with LINQ which is completely supported. Query compilation and optimization can be cached, so that multiple execution of the same query will not need to compile the LINQ lambda expressions again.

A simple LINQ query:

using (var session = Domain.OpenSession()) {
  using (var transactionScope = session.OpenTransaction()) {
    var personsNamedJohn = from message in Query<Person>.All 
                           where person.Name.StartsWith("John") 
                           select person;
    foreach (var person in personsNamedJohn )

Data storage[edit] is designed to work with arbitrary data stores, not only SQL servers. But currently only Microsoft SQL Server, PostgreSQL and an in memory database is available. An embedded database is planned so that DataObjects.NET can be used without any third party database.


DataObjects.NET has a high level of abstraction and is designed to support operations on huge data. Nevertheless, it is designed for performance and has a vast amount of optimizations. It beats other complex ORM Frameworks like NHibernate and ADO.NET Entity Framework in CRUD and Query operations .

See also[edit]


External links[edit]