Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 177980

Object-relational mapping (ORM) is a technique for mapping between object-oriented systems and relational databases.

0 votes

Why should I use an ORM like Entity Framework Core?

You should use an ORM to save you writing your own. It sounds like your problem is more that there is no consistent design choice in where you put your data access logic. … Just make that architectural design choice and ask if it works better with EF or a lighter ORM. …
Ewan's user avatar
  • 79.9k
2 votes
Accepted

Should database model POJO contain *entities* or *ids* when having 1:M, M:N relationships?

The best way is to include lists of ids rather than full objects. If you include full objects things become clunky You often want a list of all the sub objects, rather than having it split amongst p …
Ewan's user avatar
  • 79.9k
0 votes

Does references between entities of the same aggregate hurt the Aggregate Pattern from DDD?

In the same aggregation root, there are Car and Computer I think this is where you are going wrong. In your example Computer is the Aggregate Root. You can only have one 'root' object per aggreg …
Ewan's user avatar
  • 79.9k
5 votes
Accepted

Any solid reason to have getters/setters in entities? ORM, Doctrine

I used to eschew getters and setters, I would "Pah" those who put forward the reasons why they are better for the kind of reasons you suggest. Now I use them all the time without a second thought. No …
Ewan's user avatar
  • 79.9k
3 votes
Accepted

Private class in ORM Repository?

No, it's not bad to have private classes in repositories. I guess the confusion would be around why you need a private class. Rather than another option. Use an existing public class. Your Reposit …
Ewan's user avatar
  • 79.9k
5 votes
Accepted

Should I check if something exists in the db and fail fast or wait for db exception

Rather a confused question, but YES you should check first and not just handle a DB exception. First of all, in your example you are at the data layer, using EF directly on the database to run SQL. Y …
Ewan's user avatar
  • 79.9k
0 votes

Best practice for object relation mapping to execute delete/update

You should be hiding your ORM behind a repository. This allows you to optimise things like a bulk update to custom SQL where required. …
Ewan's user avatar
  • 79.9k
0 votes
Accepted

Should the ORM create the related objects (ForeignKey objects) when saving the entity?

I think the common approach is to drop EF and replace with hand coded repos. But! Here Invoice is your aggregate root object. If i do: myInvoice.Recipient.Name = "new name"; repo.Save(myInvoice); …
Ewan's user avatar
  • 79.9k
0 votes
Accepted

Dry refactoring against database

You can use a generic type IItemRepository<T> { T GetAttributeById(string id); } But you may find you have to use reflection, either to get the Id or map to the object. Sometimes its best jus …
Ewan's user avatar
  • 79.9k
5 votes

Stored procedures or ORM in web?

The problem with Stored Procedures in your case are the multiple databases. As you point out. if you have to change a sproc you will then have to deploy that change to every database. Where as if yo …
Ewan's user avatar
  • 79.9k
9 votes

Is ORM a bad tool for tree-like DB structures?

A more subtle problem is that as an ORM tries to handle all these scenarios in a generic way it gets bigger and more complicated to use. … If you have a large or complicated application, it's likely that at some point you will hit a problem with the ORM you have chosen. …
Ewan's user avatar
  • 79.9k
-4 votes

When should I use stored procedures?

I think there are three issues here. Business logic in SQL is bad. Even if it runs faster individualy, it doesnt scale. Tradiionally SPROCs should always be used for all data access as an abstractio …
Ewan's user avatar
  • 79.9k
11 votes

If Repository Pattern is overkill for modern ORMs (EF, nHibernate), what is a better abstrac...

using a Generic Repository on top of an ORM which is basically just another Generic Repository. … The answer is to use the basic Repository pattern to hide your ORM
Ewan's user avatar
  • 79.9k
3 votes

Is it a bad idea to put externally dependent logic in ORM classes?

I think you are correct in your concerns. In both cases I would separate the repository functions from the object. The document object seems particularly bad in that the logic takes place in the con …
Ewan's user avatar
  • 79.9k
2 votes

What's best practice when putting an abstraction layer over an ORM?

A. you can't inject a mock for testing B. you create tight coupling with your ORM classes C. you cant control the way in which the ORM is used ie. drop the tables, run a low performance query etc the … points you outline are ways people have tried to get around these problems 1: hides your ORM classes from the rest of the project and allows mocking 2: I agree with you on this, but it does reduce the …
Ewan's user avatar
  • 79.9k

15 30 50 per page