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

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

问题描述

将定制(通常是易失性)数据引入实体模型类的最佳做法是什么?这听起来像是一个不好的做法,但它似乎是一个相当普遍的情况。在我们最近的Web应用程序中,我们开发了一个合适的模型,在大多数情况下,我们很好的加载模型实体。但有些情况下,我们不能负载整个实体层次结构;我们需要加载,例如两个SQL COUNT的结果或可能一些附加信息(或嵌入在模型实体内部)。因此,基本上,要求和条件是:


  1. 这是一个Web应用程序,其中99.9999999999%的操作都是读取操作。 p>


  2. 他们不需要处理或做任何复杂的业务逻辑。


  3. 在几个性能关键的情况下,我们需要加载不符合任何模型属性的SQL聚合结果


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


通常如何解决这个问题,而不用对你的ORM做太多的工作(例如db的原始数据)?我确定这已经讨论了很多次,但我不能找出一个好的Google查询来找到有用的东西。



编辑:自后来我意识到问题不是很好,我决定重新制定它,并开始新的

解决方案

如果你只是从浏览器获取关系数据,在它们之间很少或没有行为,它听起来像你试图解决关系



我可能倾向于完全不使用面向对象的方法。



我团队最近重写了一个应用程序,问什么是最简单的事情,可能工作?和与问题最接近的语言是什么?。



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


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. It’s a web application where 99.9999999999% of all operations are read operations.

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

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

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

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.

解决方案

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.

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.

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

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

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