I have created domain model and define entities, value objects, Services and so on. Now, my query is that i have an entity called “Company” which has around 20+ attributes and i want to bind a dropdownlist control in one of my page that require only two attributes i.e. company.Name, company.Id. Why should i use such a heavy entity having 20+ attributes to bind the dropdownlist.
Is there any way to handle this considering the performance in mind as well.
Thanks in advance.
Question is not that much DDD related. It’s about performance.
As I do – I do not care if there is 1 or 20 attributes as long as those attributes does not come from separate tables. There isn’t high difference if select picks up 1 or 20 fields, but there is noticeable difference if select starts to join other tables and there is highly noticeable difference when there’s select n+1.
So – when I retrieve list of
Companythrough my ORM in order to create selectlist, it is smart enough to run sql select only overCompanytable and lazy load other things if they are necessary (which aren’t in this particular case).Luckily – I’m not developing systems that demands ultra high performance so I don’t care if it takes 1 or 20 fields. If I did – I doubt that I would use ORM anyway.
For some other persistence mechanisms – it might not be a problem at all. E.g. – if You are using document database, You can store/retrieve whole aggregate into one document cause it’s schema less. Performance penalty goes down drastically.