Db4o Mvc应用程序体系结构 [英] Db4o Mvc Application Architecture

查看:108
本文介绍了Db4o Mvc应用程序体系结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在测试Db4o的asp.net MVC 2应用程序想法,但是我不确定在某些方面进行最佳处理.

I am currently testing out Db4o for an asp.net MVC 2 application idea but there are a few things I'm not quite sure on the best way to proceed.

我希望我的应用程序使用可猜测的路由,而不是使用ID来引用我的实体,但是我还认为我需要某种ID来更新场景.

I want my application to use guessable routes rather than Id's for referencing my entities but I also think I need Id's of some sort for update scenarios.

例如,我想要

/country/usa代替/country/1

/country/usa instead of /country/1

我可能想更改键名(可能不是在一个国家,而是在其他实体上),因此我想在更新其字段之前需要一个ID作为引用来检索该对象.从其他评论看来,UUID的使用似乎有点长,并且无论如何还是希望使用我自己的ID来完全分离关注点.

I may want to change the key name though (not perhaps on a country but on other entities) so am thinking I need an Id to use as the reference to retrieve the object prior to updating it's fields. From other comments it seems like the UUID is a bit long to be using and would prefer to use my own id's anyway for clean separation of concerns.

在看KandaAlpha项目时,我不太热衷于设计的某些方面,而是更喜欢S#arp体系结构,它们使用[domainsignature]和EntityWithTypedId,IEntityDuplicateChecker,IHasAssignedId,BaseObject之类的东西和IValidatable可以在其实体中控制插入/更新行为,这些行为看起来更干净,更可扩展,涵盖了验证并且很好地封装在核心和基础存储库类中.

Looking at both the KandaAlpha project I wasn't too keen on some aspects of the design and prefer something more along the lines of S#arp architecture where they use things like the [domainsignature] and EntityWithTypedId, IEntityDuplicateChecker, IHasAssignedId, BaseObject and IValidatable in their entities to control insert/update behaviour which seems cleaner and more extensible, covers validation and is encapsulated well within the core and base repository classes.

那么将S#arp体系结构移植到Db4o还是有意义的,还是我仍然在考虑oodb世界中的rdbms?

So would a port of S#arp architecture to Db4o make sense or am I still thinking rdbms in an oodb world?

还有在Db4o中管理索引(包括上述唯一索引)的最佳实践吗? 例如,它们是否应该基于模型元数据并在引导程序中使用DI进行加载,还是应该像Automapper.CreateMap那样进行加载?

Also is there a best practice for managing indexes (including Unique ones as above) in Db4o? Should they be model metadata based and loaded using DI in a bootstrapper for example or should they be loaded more like Automapper.CreateMap?

我知道这是一个非常棘手的问题,但是任何想法,想法或建议的阅读材料都将受到赞赏.

Its a bit of a rambling question I know but any thoughts, ideas or suggested reading material is greatly appreciated.

谢谢 Mac

推荐答案

此问题包含许多不同方面.我们开始吧.

This question contains a lot of different aspects. Let's start.

通常db4o使用 object-identity 来区分不同的对象.因此,通常您不使用任何ID.但是,在Web应用程序中,您会在请求之间失去对象身份,因此无法使用id.

Normally db4o uses the object-identity to distinguish the different objects. So normally you don't use any ids. However in a web application you loose the object-identity between the requests, so there's no way around using ids.

可以使用db4o的内部对象ID .但是,对数据库进行碎片整理时,此ID可能会更改.我想您想拥有永久性的ID来启用链接等.因此,这些ID是不可选择的. Guid或 db4o-UUID 可以用作ID.但是,两者都相当长.

The internal object ids of db4o can be used for that. However this ids may change when you defragment the database. I guess that you want to have permanent ids to enable links etc. So then these ids aren't a option. The Guid's or the db4o-UUIDs can be used as ids. However both quite are long.

我认为最好的解决方案是添加一个表示对象ID的字段.然后,您对该字段进行索引,并可能添加唯一的约束.这使您还可以使用不同种类的ID.例如,这可以使您使用"/country/usa",因为您使用ISO代码作为ID.对于简单的数字自动ID,您可以使用巧妙的ID生成器

I think the best solution is to add a field which represent the ID of the object. Then you index that field and maybe add an unique constraint to it. This enables you also to used different kinds of ids. For example this could enable you the '/country/usa', because you use the ISO-Code as id. For simple numeric auto-ids you could use a clever id-generator.

我不知道您提到的两个框架(KandaAlpha,S#arp).听起来这些东西仍然有意义.您可以实现添加特定行为的接口或属性.例如,一个属性告诉系统哪个字段是对象的ID.该属性确保该字段被索引,系统知道如何查询等.

I don't know the two frameworks (KandaAlpha, S#arp) you mentioned. It sounds that the stuff still makes sense. You implement Interfaces or Attributes which add specific behavior. For example an attribute which tells the system what field is the id of the object. The attribute ensures that this field is indexed, that the system know how to query etc.

在我的应用程序中,索引是通过属性添加的.您可以使用db4o-IndexedAttribute.或者,您可以添加自己的.总的来说,我认为两种方式都可以,显式配置或对元数据进行相同的配置.

In my application the indexed are added through attributes. There's an db4o-IndexedAttribute you can use. Or you could add your own. In general I think both ways, explicitly configuring or doing the same with meta-data are ok.

这篇关于Db4o Mvc应用程序体系结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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