ORM(Object Relational Mapping)
I aim to explain what an ORM does, as well as the pros and cons of using them in your projects.
What is an ORM?
Object-relational-mapping is the idea of being able to write queries , as well as much more complicated ones, using the object-oriented paradigm of your preferred programming language.

Select * from users where email = 'test@test.com';
///This is a Sql code.
var orm = require('generic-orm-library');
var user=orm("users").where({email:'test@test.com'});
//In these rows,we ve used an imaginary ORM library to
execute the exact same query,except we can write it in C#.
What are some pros of using ORM?
*It abstracts away the database system so that switching from MySQL to PosttgreSQL or whatever flavor you prefer,is easy..
*Depending on the ORM you get a lot of advanced features out of the box,such as support for transactions,connection pooling,seeds,streams and all sorts of other goodies.
*Many of the queriest you write will perform better than if you wrote them yourself.
What are some cons of using ORM?
*As a developer, it is important to understand what is happening under the hood. Since ORMs can serve as a crutch to avoid understanding databases and SQL, it can make you a weaker developer in that portion of the stack.
Instance : 2;
we have books class and
we want to get which writer name is "Orhan Pamuk" ;
List books= new List();
sql = "SELECT * FROM LibraryWHERE Writer= 'Orhan Pamuk'";
data = query(sql); // I over simplify ...
while (row = data.next())
{
books k = new Kitap();
k.Writer=row["Writer"];
books.add(kitap);
}
After ORM Library it can be seen like this ;
List Books= db.Books.Where(x=>x.Writer=="Orhan Pamuk").ToList();
references:blog.bitsrc.io/MarioHoyos, emrebostan.com/orm
Last updated
Was this helpful?