DataObjects.NET
Encyclopedia
DataObjects.Net is a persistence and object-relational mapping
Object-relational mapping
Object-relational mapping in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language...

 framework for the Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

 .NET Framework
.NET Framework
The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...

. It allows the developer to define the business logic
Business logic
Business logic, or domain logic, is a non-technical term generally used to describe the functional algorithms that handle information exchange between a database and a user interface.- Scope of business logic :Business logic:...

 (persistent objects) directly in one of the .NET languages like C#. The persistent objects can be retrieved by LINQ
LINQ
Linq is a word-based card game from Endless Games, introduced at the American International Toy Fair in 2005.Game play requires at least four players, two of whom are dealt cards with the same word, while the others receive blanks. The goal is to gain points by correctly naming the players with...

 queries. Persistent data can be stored in SQL Server
SQL Server
SQL Server may refer to:* Any database server that implements the Structured Query Language* Microsoft SQL Server, a relational database server from Microsoft* Sybase SQL Server, a relational database server developed by Sybase...

s 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

Application development with DataObjects.Net follows the domain-driven design
Domain-driven design
Domain-driven design is an approach to developing software for complex needs by deeply connecting the implementation to an evolving model of the core business concepts...

 principle. The model (business logic) can be declared directly and completely in source code using attributes
Attribute (computing)
In computing, an attribute is a specification that defines a property of an object, element, or file. It may also refer to or set the specific value for a given instance of such....

. 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
Revision control
Revision control, also known as version control and source control , is the management of changes to documents, programs, and other information stored as computer files. It is most commonly used in software development, where a team of people may change the same files...

 and visual class design tools.

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

[HierarchyRoot]
public class Person: Entity
{
[Field, Key]
public Guid Id { get; private set; }

[Field(Length = 100)]
public string Name { get; set; }
}

Unlike NHibernate
NHibernate
- External links :*** *NuGet...

 DataObjects.net 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(session) { Name = "John Doe" };
person.Name = "Jane Doe";
transactionScope.Complete;
}

Due to the use of session scopes and transaction scopes these transactional
Database transaction
A transaction comprises a unit of work performed within a database management system against a database, and treated in a coherent and reliable way independent of other transactions...

 modifications are ACID
ACID
In computer science, ACID is a set of properties that guarantee database transactions are processed reliably. In the context of databases, a single logical operation on the data is called a transaction...

. Because these persistent classes do not use methods like session.Save(person) some other mechanism must come into play to store the data. DataObject.Net uses aspect-oriented programming
Aspect-oriented programming
In computing, aspect-oriented programming is a programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns...

 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
Lazy loading
Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. It can contribute to efficiency in the program's operation if properly and appropriately used...

 and caching
Cache
In computer engineering, a cache is a component that transparently stores data so that future requests for that data can be served faster. The data that is stored within a cache might be values that have been computed earlier or duplicates of original values that are stored elsewhere...

 behind the scenes.

LINQ queries

Unlike POCO
Poco
Poco is an Southern California country rock band originally formed by Richie Furay and Jim Messina following the demise of Buffalo Springfield in 1968. The title of their first album, Pickin' Up the Pieces, is a reference to the break-up of Buffalo Springfield. Highly influential and creative,...

 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
LINQ
Linq is a word-based card game from Endless Games, introduced at the American International Toy Fair in 2005.Game play requires at least four players, two of whom are dealt cards with the same word, while the others receive blanks. The goal is to gain points by correctly naming the players with...

 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 expression
Lambda expression
Lambda expression may refer to:*Anonymous function*Lambda calculus#Definition...

s again.

A simple LINQ query:

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

foreach (var person in personsNamedJohn )
Console.WriteLine(person.Name);

transactionScope.Complete;
}
}

Data storage

DataObjects.net is designed to work with arbitrary data stores, not only SQL servers. But currently only Microsoft SQL Server
Microsoft SQL Server
Microsoft SQL Server is a relational database server, developed by Microsoft: It is a software product whose primary function is to store and retrieve data as requested by other software applications, be it those on the same computer or those running on another computer across a network...

, PostgreSQL
PostgreSQL
PostgreSQL, often simply Postgres, is an object-relational database management system available for many platforms including Linux, FreeBSD, Solaris, MS Windows and Mac OS X. It is released under the PostgreSQL License, which is an MIT-style license, and is thus free and open source software...

 and an in memory database is available. An embedded database
Embedded Database
An embedded database system is a database management system which is tightly integrated with an application software that requires access to stored data, such that the database system is “hidden” from the application’s end-user and requires little or no ongoing maintenance...

 is planned so that DataObjects.Net can be used without any third party database.

Performance

DataObject.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
NHibernate
- External links :*** *NuGet...

 and ADO.NET Entity Framework
ADO.NET Entity Framework
ADO.NET Entity Framework is an object-relational mapping framework for the .NET Framework.-Overview:ADO.NET Entity Framework abstracts the relational schema of the data that is stored in a database and presents its conceptual schema to the application...

 in CRUD and Query
Query optimizer
The query optimizer is the component of a database management system that attempts to determine the most efficient way to execute a query. The optimizer considers the possible query plans for a given input query, and attempts to determine which of those plans will be the most efficient...

operations
.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK