.NET Persistence API: Difference between revisions

Content deleted Content added
No edit summary
 
(32 intermediate revisions by 22 users not shown)
Line 1:
The '''.NET Persistence API''', also referred to as '''NPA''', is a persistence and [[object–relational mapping]] (ORM) specification for the [[.NET Framework|.NET framework]].<ref>[http://www.npersistence.org/ NPersistence | JPA for the .NET platform]</ref>
{{AFC submission|||ts=20111229001124|u=Moshehoadley|ns=5}}<!--- Important, do not remove this line before article has been created. --->
NPersistence, also reffered to as NPA, is a [[.NET_Framework|.NET framework]] specification that standards [[Object-Relational_Mapping|Object Relational Mapping (ORM)]]. NPersistence is based on the [[Java_Persistence_API|JPA]] architecture from the world of [[Java|JAVA]].
The NPersistence spec provides a loose coupling between the host application in need of persistence services and the ORM provider that supplies them.
NPersistence offers a set of standard APIs with which an application can meet all its persistence needs.
 
NPA is based on the [[Java Persistence API]] (JPA), which is the standard persistence API in the [[Java (programming language)|Java]] world. NPA follows JPA by providing a complete persistence API and a rich set of ORM features.<ref name=autogenerated1>{{Cite web |url=http://www.npersistence.org/faq |title=FAQ {{!}} NPersistence |access-date=2018-08-24 |archive-url=https://web.archive.org/web/20120426082101/http://www.npersistence.org/faq |archive-date=2012-04-26 |url-status=dead }}</ref><ref>[https://stackoverflow.com/questions/2756307/what-is-the-equivalent-of-jpa-in-net c# – What is the equivalent of JPA in .NET? – Stack Overflow]</ref>
==Motivation==
Without a standard for ORM services, host applications which need persistence services, use a specific ORM vendor (usually [[ASP.NET|ASP.NET]] or [[NHibernate]] in the .NET framework) by using the vendor specific APIs. This creates a bondage between the host application and the ORM vendor which is very difficult to untie. The host application will need a lot of work in order to switch to another ORM vendor (where the same bondage problem will continue).
With NPersistence, a host application will use the NPersistence APIs which are implemented by the different ORM vendors. An ORM vendor may be replaced with zero impact on the host application.
 
==Technology Motivation ==
The main purposes of the .NET Persistence API (NPA) are:<ref name=autogenerated1 />
NPersistence offers the following:
* To provide a vendor-free persistence API for .NET, making switching from one persistence provider to another easier (avoiding [[vendor lock-in]]).
* A set of APIs for saving, deleting, retrieving and querying entities.
* To provide a cross-language persistence API by extending the popular [[Java Persistence API|Java Persistence API (JPA)]] to all the .NET programming languages.
* Allow persistence of [[Plain_Old_CLR_Object|POCO (plain old CLR objects)]] objects to a database. Such persistable classes are called Entities.
* Marking classes as entities is done by:
** Annotations - meta data added to the source code files.
** An [[Xml]] file specifing the entity mapping.
A complete view of NPersistence is provided in the project's website<ref>http://www.npersistence.org</ref> at the reference documentation.
 
==Implementation Technology ==
The main features of NPA include:<ref>{{Cite web |url=http://www.npersistence.org/api-reference |title=API Reference |access-date=2018-08-24 |archive-url=https://web.archive.org/web/20120426082146/http://www.npersistence.org/api-reference |archive-date=2012-04-26 |url-status=dead }}</ref><ref>[http://nugetmusthaves.com/Package/NPersistence NPersistence – NuGet Must Haves]</ref>
NPersistence is a standard/specification and is not an ORM provider by itself. An implementation of the NPersistence spec by an ORM vendor is required in order to use it.
* Object-oriented API for working against databases (usually RDBMS).
Currently, such an implementation exists for the NHibernate ORM provider.
* Query language, based on SQL, for retrieving data from the database in an object oriented manner.
* Support of persisting [[Plain Old CLR Object|POCO (plain old CLR objects)]] objects (entities).
* Two methods for marking classes as entity classes and for specifying other settings:
** Using attributes – meta data is embedded in class definitions in the source code.
** Using external XML – meta data is specified in external [[XML]] resource files.
 
== Implementations ==
NPA is a persistence specification. To use NPA an implementation of the specification is required.
Persistence and ORM vendors can provide their own implementations of NPA.
 
First implementation, NPA for [[NHibernate]], was released in December 2011.<ref>{{Cite web |url=http://www.npersistence.org/nhibernate |title=NPA for NHibernate |access-date=2011-12-30 |archive-url=https://web.archive.org/web/20120426082225/http://www.npersistence.org/nhibernate |archive-date=2012-04-26 |url-status=dead }}</ref><ref>[https://archive.today/20130928184005/http://forums.anandtech.com/archive/index.php/t-2108535.html What is the equivalent of Java Persistence API for .NET? – AnandTech Forums]</ref>
 
== References ==
{{Reflist}}
 
== External links ==
{{Wikibooks|.NET Development Foundation}}
*{{Official website|www.npersistence.org}}
 
{{.NET Framework}}
 
{{DEFAULTSORT:NET Persistence API}}
 
[[Category:.NET|Persistence API]]
== References ==
[[Category:Object–relational mapping]]
{{reflist}}
[[Category:Cross-platform software]]
*
*
*
*