ORM 对数据库元数据有什么用处?
我正在阅读有关 ORM 的内容,我读到的其中一篇描述说 ORM 与数据库元数据交互。
为什么这很重要或相关?
据我了解,元数据只是描述数据库包含内容的一种方式。例如,数据库可能有一个内部表,其中列出了已创建的用户表。为什么这样的东西对 ORM 有用?
I was reading about ORMs and one of the descriptions I read said that the ORM interacts with database metadata.
Why is this important or relevant?
Metadata, as I understand, is just a way of describing what the database contains. So, for example, the database might have an internal table that lists what user tables have been created. Why would something like this be useful to an ORM?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这意味着 ORM 将数据库的模式或结构映射到对象。通常,这意味着将表映射到类(用户表到用户类),将字段映射到属性(年龄字段到 User.Age 属性),然后每个记录代表该对象的一个实例。
What this means is that the ORM maps the schema, or structure, of the database to objects. Typically, this means mapping tables to classes (User table to User class), fields to attributes (Age field to User.Age attribute), and each record then represents an instance of that object.
ORM 使用元数据生成用于访问表的代码。例如,如果它是日期列,那么它会生成将该列作为日期处理的代码。
它将读取外键和主键以在代码中构建关系以及生成正确的 SQL 语法。
这只是它使用元数据的几种方式。
The ORM uses the metadata to generate the code used to access the tables. For example, if it's a date column then it generates the code to deal with that column as a date.
It will read foreign keys and primary keys to build relationships in the code as well as for generating the proper SQL syntax.
This is just a few of the ways it uses the metadata.