域模型序列号 [英] domain model sequence number

查看:305
本文介绍了域模型序列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要根据给定的前缀码为项目分配下一个序列号。所以你结束了替代号码,如PROJ_ABC_001,PROJ_ABC_002,PROJ_XYZ_001,PROJ_XYZ_002等。

I have a need to assign the next sequence number for a Project according to a given prefix code. So you wind up with alternate id numbers like PROJ_ABC_001, PROJ_ABC_002, PROJ_XYZ_001, PROJ_XYZ_002, etc.

虽然这个需要是非常具体的,我建议有一个更一般的以及常见的情况,其中企业使用作为顺序整数的替代标识,以便识别不同的客户,项目,订单 - 无论如何。

While this need is quite specific, I would suggest that there is a more general and common case where businesses use alternate ids that are sequential integers in order to identify different Customers, Projects, Orders - whatever.

当然这些不是主键数据库。虽然数据库是维护和生成序列号的合理位置,但只有应用程序知道给定用例的具体规则。

Of course these aren't primary keys in the database. And while databases are a logical place to maintain and generate a sequence number, only the application knows the specific rules of a given use case.

您是否曾经处理过序列号作为应用程序中的域对象?您可以在多用户环境中提出任何设计模式吗?

Have you ever treated a sequence number as a domain object in an application? Can you suggest any design pattern(s) to do so in a multi-user environment?

干杯,

Berryl

Cheers,
Berryl

推荐答案

我在这里找到的最接近的答案是沿着相关的帖子

The closest answer I found here was along the lines of the accepted answer for a related post.

发布的NHibernate比我想要的要多得多,所以这是一个半心半意的答案。喜欢看到更多的技术不可知(即设计模式)的答案。

That posting is much more NHibernate specific than I'd like, so this is a half-hearted answer. Love to see a more technology agnostic (ie, design pattern) type of answer.

干杯,

Berryl

Cheers,
Berryl

这篇关于域模型序列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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