Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Object–relational mapping
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Overview== Implementation-specific details of storage drivers are generally wrapped in an API in the programming language in use, exposing methods to interact with the storage medium in a way which is simpler and more in line with the paradigms of surrounding code. The following is a simple example, written in [[C Sharp (programming language)|C#]] code, to execute a query written in [[SQL]] using a database engine. <syntaxhighlight lang="csharp"> var sql = "SELECT id, first_name, last_name, phone, birth_date, sex, age FROM persons WHERE id = 10"; var result = context.Persons.FromSqlRaw(sql).ToList(); var name = result[0]["first_name"]; </syntaxhighlight> In contrast, the following makes use of an ORM-job API which makes it possible to write code that naturally makes use of the features of the language. <syntaxhighlight lang="csharp"> var person = repository.GetPerson(10); var firstName = person.GetFirstName(); </syntaxhighlight> The case above makes use of an object representing the storage repository and methods of that object. Other frameworks might provide code as static methods, as in the example below, and yet other methods may not implement an object-oriented system at all. Often the choice of paradigm is made for the best fit of the ORM into the surrounding language's design principles. <syntaxhighlight lang="csharp"> var person = Person.Get(10); </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)