将消费者定义的汇总(例如SQL计数)与' pure'模型对象? [英] Marrying up consumer-defined aggregates (e.g. SQL counts) with 'pure' model objects?

查看:56
本文介绍了将消费者定义的汇总(例如SQL计数)与' pure'模型对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将自定义(通常易失)数据引入实体模型类的最佳实践是什么?首先,这听起来似乎是一种不好的做法,但这似乎是很常见的情况。在我们最近的Web应用程序中,我们已经开发了合适​​的模型,并且在大多数情况下,可以加载模型实体。但是在某些情况下,我们负担不起加载实体的整个层次结构。例如,我们需要在模型实体的旁边(或嵌入在其中)加载几个SQL COUNT的结果或可能加载一些其他信息。因此,基本上,要求和条件是:

What is the best practice of introducing custom (typically volatile) data into entity model classes? This may sound like a bad practice first, but it seems to be quite a common scenario. In our recent web application we have developed a proper model and in most cases we are fine with loading model entities. But there are cases where we cannot afford loading an entire hierarchy of entities; we need to load, say, results of a couple of SQL COUNT’s or possibly some additional information alongside (or embedded inside) the model entities. So basically, the requirements and conditions are:


  1. 这是一个Web应用程序,其中所有操作的99.9999999999%为读取操作。

  1. It’s a web application where 99.9999999999% of all operations are read operations.

他们不需要处理或执行任何复杂的业务逻辑。我们只需要快速将数据获取到HTML。

They don’t need to process or do any complicated business logic. We just need to get data quickly to HTML.

在一些性能至关重要的情况下,我们需要加载不适合任何模型属性的SQL聚合结果。

In several performance critical cases, we need to load results of SQL aggregates which don’t fit any model properties.

如果需要,我们需要一种可扩展的方式来引入任何新的自定义数据。

We need an extensible way to introduce any new custom data if needed.

通常如何在不解决ORM过多(例如来自db的原始数据)的情况下解决此问题?我确信已经讨论了很多次了,但是我找不到一个好的Google查询来找到有用的东西。

How do you usually solve this issue without working too much around your ORM (for instance raw data from db)? I’m sure this has been discussed many times, but I cannot figure out a good Google query to find anything useful.

编辑:后来我意识到问题不是很完善,我决定重新制定问题,然后开始一个新问题

Edit: Since I later realized the question was not very well formed, I decided to reformulate it and start a new one.

推荐答案

如果您只是在与浏览器之间获取关系数据,而两者之间几乎没有行为,则听起来像是您试图解决关系问题OO范式的问题。

If you're just getting relational data to and from a browser, with little or no behavior in between, it sounds like your trying to solve a relational problem with an OO paradigm.

我可能倾向于完全放弃面向对象的方法。

I might be inclined to dispense with the Object Oriented approach altogether.

我团队最近通过询问可能最简单的方法是什么?重写了应用程序。和最接近问题的语言是什么?。我们的新应用取代了OO,最终变得更小,更快,更便宜10倍。

Me team recently rewrote an application by asking "What is the simplest thing that can possibly work?" and "What is the closest language to the problem?". Our new app, replacing an OO one, ended up being 10 times smaller, faster, and cheaper.

我们在数据库服务器上使用了SQL,存储过程,XML库, XSLT(获取HTML)和javascript。

We used SQL, stored procedures, XML libraries on the DB server, XSLT (to get the HTML), and javascript.

这篇关于将消费者定义的汇总(例如SQL计数)与' pure'模型对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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