📈
Entity FrameWork(EF) Ado.Net
  • Entity FrameWork
  • ORM(Object Relational Mapping)
  • Lazy Loading vs Eager Loading
  • Dapper
Powered by GitBook
On this page
  • What is an ORM?
  • What are some pros of using ORM?
  • What are some cons of using ORM?
  • Instance : 2;

Was this helpful?

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.

PreviousEntity FrameWorkNextLazy Loading vs Eager Loading

Last updated 4 years ago

Was this helpful?

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