LINQ to SQL Automatic database synchronization

mac2022-06-30  12

[索引页]
Automatic database synchronization with a royalty-free .Net component 如果你使用 LINQ to SQL将数据库中数据转成对象,但我们要修改LINQ to SQL Classes中的对象,那就要手动去修改数据库,那如果我们去修改数据库,那我们又要回来重新修改LINQ to SQl Classes,是不是很麻烦.这里有一个组件能帮助我们解决这个问题.让LINQ to SQL Classes与数据库同步. 地址
一:介绍
Database Synchronization Componnent.产生是为开发者为全部的应用程序面对同样的数据库结构的而要做的很多乏味和常规的操作.需要频繁更新影响工程实现. 现有工具解决问题不够广泛,如大部分案例都需要手动工作,为数据库的与客户端数据的同步安装昂贵的软件,同时也要为数据结构的每一次变更进行修补. Database Restyle-Library提供一个解决这个问题新的方案.首先,它不是一个应用程序;它是一个能整合进入你的应用程序的组件.这个允许你在客户端不安装另外的软件和不用开发修补.都由这个组件同步执行,它只需要调用你连接数据库调用更新方法.你能见组件放入你的应用程序不需要任何费用,不管任何应用程序类型(WinForms, ASP.NET, Console, WPF,)等.数据库结构保存为XML文件,并且源于文件所发布(file, resource等). 它还能使用LINQ to SQL模型同时也能在任何现在有的数据库schemas中初始化数据库结构.结合几行代码就能足够创建或更新数据库.并所的生成数据库对象图到执行DLL脚本的都是在开发者的总控制下处理. Database Restyle - Library™ 提供通过应用程序创建数据库结构的功能.更改商业对象将自动映射到数据库的schema中. 还有Database Restyle - Library™帮助你缩小在数据库改进和排除错误上费用.它还防止你的扩大程序.这个libary的使用不需要培训,如在大部分的案例它只需要调用两个方法:一个是在开发者端调用Reverse方法得到数据库结构和在客户端调用Update方法同步更新数据库.这里的Reverse程序是通过在工程中的PreBuild事件的CommandLine工具来执行.所以应用程序完全自动构建并且保证在新的数据库schema中一定包含其内容. Database Restyle - Library™ 是一个为按照商业对象结构定义完整数据库结构的本质解决方案.一个程序设计,就是基于在metadata和你的应用程序符合你的任务指定和你使用的mapping工具的商业对象构成的objects graph,再形成数据库结构,这一切都会因解决数据库同步问题而被解决. Database Restyle – Library是被开发来提供给DBAs和SQL 开发者所使用.视觉工具包括在wizard mode中发送包操作和被设计保存数据库快照,对照和同步两个数据库.User-friendly 和 intuitive interface 提供给开发者能帮助它在瞬间执行所有操作.还有,开发者能立即和他们的应用程序中数据库同步数据或 为独立工具所使用. 这个产品是在SQL Server 2005 ,.NET Framework2.0和只包括托管代码部分中开发的.专业版还有完整source code.
二:Database Restyle - Library™ features
(1)Database Restyle - Library™ runtime is royalty-free. This will help you significant sum of money, as you don’t need to purchase additional licenses for your end users and clients; 帮助你控制支出,你不需要购买 licenses就能在 clients和users使用. (2)Database Restyle - Library™ is integrated directly into your application. There is no need to install extra software on the client side, this considerably reduces time and money expenses; 不需要安装另外的软件,缩小费用. (3)Works with applications of any type: WinForms, WebForms, console applications, services, WPF applications. The component can be used in .Net application of any type; 能应用在任何类型的应用程序中. (4)Support for LINQ. It is possible to use Linq to Sql model as well as any other existing database schemas as source database structure. A couple of lines of code are enough to create or update database. And the whole process from forming database object graph to executing DLL scripts is under the developer’s total control. 支持LINQ. (5)Synchronization with database of any type on the client side. No need to track down sequence of patches and so on; 能client端支持在任何类型数据库同步 (6)Ability to perform additional actions in case of sophisticated refactoring of database structure. When it is impossible to carry data from a database of old structure directly to new database, it is necessary to copy data from database to temporary storage before database refactoring and to restore data after refactoring is complete. Such behavior can be realized with the help of the following events: DatabaseSync: DatabaseUpdating and DatabaseUpdated. 能在数据库结构分解case中执行额外的行为. 当它不能立即携带旧的数据库结构进入新的数据库中时,它就需要在数据库分解从数据库中copy数据到暂时存储,再在分解完成后恢复数据.上面的每一个行为都能通过下面事件的帮助所了解:DatabaseSync: DatabaseUpdating 和 DatabaseUpdated (7)Ability to create database structure from application code, for example, on the basis of business objects. No need to track correspondence of objects of application business logic to database structure. Application can easily reorganize database structure to the required one to get full correspondence to custom business objects. It is also possible to create database structure in the application code and to carry it to MS SQL Server 2005. Carry is performed by firing a single function. 能从应用程序代码中创建数据库结构,也就是基于商业对象. 不需要跟踪符合应用程序商业逻辑的对象进入数据库结构.应用能很容易按照你相应的自定义的商业对象改编数据库结构. 还能在应用程序代码创建数据库结构和带它进入MS SQL Sever2005.这样执行只需要触发一个函数. (8)Visual Wizard Intuitive visual tool allows the snapshotting of database structure, comparison of databases and their synchronization. The work of the visual tool in the wizard mode provides user-friendly interface which allows quick saving of database snapshots, synchronization and comparison with a few mouse clicks. Saving and passing of the database snapshot simplifies and accelerates comparison and synchronization of databases on the client side. (9)Full source code is available; 完整的source (10)Contains only managed .Net code; 只包括.net托管代码 (11)Developed for SQL Server 2005. Support for latest innovations such as XML type, use of .Net assemblies, etc. 为SQL server 2005开发, 支持最新的 SQL Server 2005特性,XML类型..NET assemblies的使用等. (12)CommandLine component and instrument are included. The delivery package includes the DatabaseRestyle.exe utility that performs operations of saving snapshot and updating database from the command line; 包括CommandLine component 和instrument, 这里的发送包(delivery package)包括DatabaseRestyle.exe,它被用来执行保存快照和从命令行中更性数据库的操作. (13)Ability to save database schema as XML file. Such file can be stored in source control, easily transferred via the network and used to adjust database structure on the server in accordance with structure saved in it. 能像xml文件保存数据库schema. 每一个文件能存储在source control中,很容易为network传输 并在服务端按照保存的结构来修整数据库. (14)Automatic definition of scripts performance order subject to relations between objects. When database structure is reversed, all relations between objects are read from SQL Server. This feature and built-in system of logical dependence provide the ability to perform scripts for database reorganization in the necessary sequence. 按照对象之间的关系关系自动定义脚本执行. 当数据库结构被反转时候,所有对象之间的关系从SQL Server中读取.这个特性并且构建这个逻辑系统依赖于提供了按照所需要次序改编数据库执行脚本的能力. (15)Supported objects. Schemes, Tables, Views, Functions and stored procedures, Triggers, DLL triggers, Assemblies, User-Defined types and CLR types, Indexes and XML indexes, XML schemes collections, Constraints, Users, roles and permissions, Extended properties. 支持对象.
三下载和安装
(1)下载的是1.7版的. 这里还有Database Restyle-application这个是可以免费使用30天.我们只研究library.但这里出一点问题就是我的library不能安装,可能是我又有Vs2005,又有Vs2008的原因,所有我就用的工具把msi中的文件提取出来,将几个有用的.dll加载到工程中.这样也才使用得工作能进行.但后来我发现在每个.dll中都有PerpetuumSoftLicense.所以看来是只能使用30天拉. 主要的.dll文件又. Microsoft.SqlServer.ConnectionInfo.dll Microsoft.SqlServer.Smo.dll PerpetuumSoft.DataModel.dll PerpetuumSoft.DataModel.LinqToSql.dll PerpetuumSoft.DataModel.dll PerpetuumSoft.DataModel.UI.Windows.Forms.dll QWhale.Common.dll QWhale.Editor.dll QWhale.Syntax.dll QWhale.Syntax.Parsers.dll
四:实践
谈到LINQ to SQL有很多优点,但在解决庞大的工程时有一些问题难与解决.在工程中使用LINQ to SQL将就将决定使用LINQ to SQL Classes,这个组件要与实际数据库中的数据保持同步是很复杂的.有两个问题: 如果你决定修改LINQ to SQL Classes,这些修改就需要编译重新创建并传输到实际的数据库中.这样的方法非常难以接受. 如果你决定修改实际数据库结构,之后它可能LINQ to SQL Classes要再次编译重新创建.你需要删除旧的schema和创建新的schema.这个会导致更多麻烦如重新便宜代码和改变schema元素位置. 那其实这个组件就是解决上面两个问题. 实践我自己就做的是这个 事例. 在这个程序中有使用CreateDatabase和Reverse方法,在你下载的CSharp案例中有使用UpdateDatabase方法.
今早发现MS也有解决方案的: 这里还有一点讨论这方面的问题: http://blogs.rev-net.com/ddewinter/index.php?p=41/ (1)VSTS2005中有上面的工具可以对照schema并插入,更新,删除. 在下面去下载工具 http://www.microsoft.com/downloads/details.aspx?FamilyID=7de00386-893d-4142-a778-992b69d482ad&displaylang=en&hash=bQEgloXOTTcexNcsxuZkN1HXQls2zwyILEo431I5X9xs5dObGB4V6WCTEP3hOteWnCuYOQBfv5oVgSwW/qdCkg== http://msdn2.microsoft.com/en-us/library/bb264457(VS.80).aspx http://www.microsoft.com/downloads/thankyou.aspx?familyId=da3f11ad-bd54-4eda-b08c-4df84df0d641&displayLang=en (2)在VS2008中相关的在这里有一些说明 http://blogs.msdn.com/gertd/archive/2007/11/21/visual-studio-team-system-2008-database-edition.aspx在vs2008中在安装时候已经安装了Team Database Edition. Tools->Options->Database Tools->Design-time来配置. 你可以在你的工程中点上面菜单中的Data->schema compare->new schema comparison 来对照server与client间数据的schema 这里有一段描述: 这里有三步可以帮助你在VS2008中达到数据库的schema与你的工程中的schema同步: http://blogs.msdn.com/gertd/archive/2007/11/21/visual-studio-team-system-2008-database-edition.aspx 其中你可在ServerExplorer中点右键---》转换查看方式----》改为schema http://blogs.msdn.com/gertd/archive/2007/02/18/to-synchronize-or-to-refresh.aspx http://blogs.msdn.com/gertd/archive/2007/10/17/external-changes.aspx
worksguo 欢迎评论

转载于:https://www.cnblogs.com/worksguo/archive/2008/04/26/1172664.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)