初始化扩展类 - 设计问题

发布于 2024-12-05 01:26:30 字数 377 浏览 1 评论 0原文

我的 C# 应用程序遇到设计问题。我有一个 DAL,它为来自不同数据库的多个不同客户提供数据。到目前为止,这些数据库具有相同的表和字段名称,但现在我有一个具有不同字段名称的数据库,因为客户希望字段名称是区域设置语言而不是英语。

我该如何解决这个问题?

我目前的应用架构是基于工厂的。所以我有这个:

BusinessFactory 初始化 DAL,所以我的第一个想法是扩展 DAL,然后重写需要更改数据库字段名称的函数,并在扩展类中创建一个新函数。但是我什么时候应该初始化这个扩展类呢?

我无法从我的 BusinessFactory 中执行此操作,因为 DAL 依赖于接口。

如果我关于扩展 DAL 作为此问题的解决方案的说法完全错误,请也给我指出另一个方向。

I'm running into a design problem in my C# application. I have a DAL which supplies data for several different customers from different databases. Until now these databases have had the same tables and field names, but now i have one database which has different field names, because the customer wants the field names to be of locale language instead of english.

How do i solve this?

My current application achitecture is based on factories. So i have this:

BusinessFactory initialzes the DAL, so my first thought was to just extend the DAL and then override the function where the database field names needs to be changed and make a new function in the extending class. But when should i initialize this extending class?

I can't do it from my BusinessFactory because the DAL is depending on a Interface.

Please, also point me the other direction if I'm all wrong about extending the DAL as a solution to this problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

離殇 2024-12-12 01:26:30

我想你一定有一个客户 ->数据库映射到位,您可以根据该映射决定要连接到哪个数据库。

因此,您可以引入预处理器层来找出需要从数据库获取的列名称。因此基本上您将保留可以使用的每个客户端配置(和默认配置)。

I think you must be having a client -> db mapping in place based on which you decide that which db to connect to.

So you can introduce a pre processor layer to figure out the column names you need to get from database. So basically you will keep a per client config (and a default config) which you can use.

恍梦境° 2024-12-12 01:26:30

简单的解决方案是使用客户希望的语言创建具有列名称的视图。这样您就不必更改您的应用程序。

Simple solution would be to create Views with column names in the language your client wishes. This way you do not have to change your application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文