是一个ORM的冗余与NoSQL的API? [英] Is an ORM redundant with a NoSQL API?

查看:287
本文介绍了是一个ORM的冗余与NoSQL的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用MongoDB的(我假设其他的NoSQL数据库API称职)查询数据库的方式比SQL更加简单化。没有繁琐的SQL查询来生成并且这样。例如借此从MongoDB的-CSHARP:

with MongoDB (and I assume other NoSQL database APIs worth their salt) the ways of querying the database are much more simplistic than SQL. There is no tedious SQL queries to generate and such. For instance take this from mongodb-csharp:

using MongoDB.Driver; 
Mongo db = new Mongo(); 
db.Connect(); //Connect to localhost on the default port. 
Document query = new Document(); 
query["field1"] = 10; 
Document result = db["tests"]["reads"].FindOne(query); 
db.Disconnect();



怎么可能一个ORM甚至简化了吗?是否需要一个像样的NoSQL API之上的ORM或其他数据库抽象设备?

How could an ORM even simplify that? Is an ORM or other "database abstraction device" required on top of a decent NoSQL API?

推荐答案

恩,是的,对象 - 关系映射器是多余的,因为的MongoDB MongoDB是不是关系数据库,这是一个面向文档的数据库。

Well, yes, Object-Relational mappers are redundant with MongoDB because MongoDB isn't a relational database, it's a Document-Oriented database.

所以不是SQL的,你写JSON查询。除非你真的,的真正的要写入原始JSON,而不是,比方说,LINQ的,那么你还是会希望使用一个映射。如果你不希望建立一个反对的MongoDB本身耦合,那么你不希望传递的实际文件物体周围,你想将它们映射到实际波苏斯。

So instead of SQL, you write queries in JSON. Unless you really, really want to write raw JSON, as opposed to, say, Linq, then you're still going to want to use a mapper. And if you don't want to create coupling against MongoDB itself, then you don't want to pass actual Document objects around, you want to map them to real POCOs.

的映射是很多的更容易的像MongoDB的面向文档的数据库,因为你已经嵌套的文件,而不是关系,但并不意味着它完全消失。它只是意味着你已经取代一种类型的阻抗不匹配的一个不同,略少戏剧性的不匹配。

The mapping is much easier with a document-oriented DB like MongoDB, because you have nested documents instead of relations, but that doesn't mean it goes away completely. It just means you've substituted one type of "impedance mismatch" for a different, slightly-less-dramatic mismatch.

这篇关于是一个ORM的冗余与NoSQL的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆