简体   繁体   English

CSLA.NET是适用于多个数据库的正确解决方案吗?

[英]Is CSLA.NET a right solution for multiple databases?

I have an application the currently connect to a database. 我有一个当前连接到数据库的应用程序。 But I have a plan to slice the data in this database to multiple databases. 但是我有一个计划将该数据库中的数据切成多个数据库。

For example, I have 10,000 records in table Test_Table_1 and right now it is located in the only one database. 例如,我在表Test_Table_1中有10,000条记录,现在它位于唯一的一个数据库中。 Now, I want to move 5,000 records from this database to a new database, with the same table name. 现在,我想将5,000条记录从该数据库移至具有相同表名的新数据库。 So, I would have 2 databases, the original one would contain the first 5,000 records and the new data-center would contain the rest (5,000 records.) 因此,我将拥有2个数据库,原始数据库将包含前5,000条记录,而新数据中心将包含其余数据库(5,000条记录)。

The challenge is on the application. 挑战在于应用程序。 I need to update it by reading a configuration value from a configuration file to check which data center it would connect to. 我需要通过从配置文件中读取配置值来更新它,以检查它会连接到哪个数据中心。

Here are my questions: 这是我的问题:

  1. Is CSLA.NET a right solution for this problem? CSLA.NET是解决此问题的正确解决方案吗?
  2. Is there a feature on CSLA.NET that allow me to switch between data-centers when one of them dead? CSLA.NET上是否有一项功能可以让我在其中一个数据中心失效时在数据中心之间切换?

CSLA is not a data access framework or ORM, it is a business layer framework. CSLA不是数据访问框架或ORM,它是业务层框架。

It does abstract the concept of the database, making it possible for your business layer to use data from multiple databases. 它确实抽象了数据库的概念,使您的业务层可以使用来自多个数据库的数据。

Interaction with the database(s) is the responsibility of your data access layer (DAL). 与数据库的交互是您的数据访问层(DAL)的责任。 CSLA provides some high level functionality so it invokes your DAL in a consistent manner, but it is up to you to implement your DAL. CSLA提供了一些高级功能,因此它以一致的方式调用DAL,但是要由您来实现DAL。

One important consideration when building business domain objects that include data from multiple databases is that the key values from each database table are usually required to do any database updates if the user saves the object's data. 构建包含来自多个数据库的数据的业务域对象时,一个重要的考虑因素是,如果用户保存了对象的数据,则通常需要每个数据库表的键值进行任何数据库更新。 As a result you should expect to store those key values in your business object (perhaps as private properties). 因此,您应该期望将这些键值存储在业务对象中(也许作为私有属性)。 The same is true for concurrency values such as timestamps. 并发值(例如时间戳)也是如此。

CSLA is not a data access framework. CSLA不是数据访问框架。 It provides business objects methods that abstract the data access implementation. 它提供了抽象数据访问实现的业务对象方法。 But you would still have to implement the data access layer using ADO .NET/some kind of ORM/etc. 但是您仍然必须使用ADO .NET /某种ORM / etc来实现数据访问层。

I would look into NHibernate and the Shards package. 我将研究NHibernate和Shards包。

http://nhforge.org/ http://nhforge.org/

http://nuget.org/packages/NHibernate.Shards/ http://nuget.org/packages/NHibernate.Shards/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM