資源簡介
使用辦法:
找到CodeSmith的SchemaProviders目錄,替換文件,即可。壓縮包中也有.cs文件
如果打開失敗重新選擇一下驅動就可以了

代碼片段和文件信息
//?====================================================================
//?Description:?MySQL?Schema?Provider?for?CodeSmith?5.x
//?Author:?David?Neal?--?www.ChristianASP.NET
//?Modified?By:?Blake?Niemyjski?--?http://windowscoding.com
//?====================================================================
using?System;
using?System.Collections.Generic;
using?System.Data;
using?System.Data.Common;
using?System.Text;
using?System.Text.Regularexpressions;
namespace?SchemaExplorer
{
????///?
????///?MySQL?Schema?Provider
????///?
????public?class?MySQLSchemaProvider?:?IDbSchemaProvider
????{
????????#region?Properties
????????#region?IDbSchemaProvider?Members
????????///?
????????///?Gets?the?name?of?this?schema?provider.
????????///?
????????///?
????????public?string?Name
????????{
????????????get?{?return?“MySQLSchemaProvider“;?}
????????}
????????///?
????????///?Gets?the?description?for?this?schema?provider.
????????///?
????????///?
????????public?string?Description
????????{
????????????get?{?return?“MySQL?Schema?Provider“;?}
????????}
????????#endregion
????????#endregion
????????#region?public?string?GetDatabaseName(string?connectionString)
????????///?
????????///?Gets?the?name?of?the?database.
????????///?
????????///?The?connection?string?used?to?connect?to?the?target?database.
????????///?The?name?of?the?database
????????public?string?GetDatabaseName(?string?connectionString?)
????????{
????????????//?Problem?is?INFORMATION_SCHEMA?appears?to?retrieve?information?for
????????????//?every?database?instead?of?just?the?current?database
????????????//?So?we‘ll?need?to?parse?the?connection?string?instead?of?pulling
????????????//?the?current?database?directly
????????????Regex?databaseNameRegex?=?new?Regex(?@“Database\W*=\W*(?se>[^;]*)“?RegexOptions.IgnoreCase?);
????????????Match?databaseNameMatch?=?databaseNameRegex.Match(?connectionString?);
????????????if?(?databaseNameMatch.Success?)
????????????{
????????????????return?databaseNameMatch.Groups[?“database“?].ToString();
????????????}
????????????return?connectionString;
????????}
????????#endregion
????????#region?public?string?GetViewText(string?connectionString?ViewSchema?view)
????????///?
????????///?Gets?the?definition?for?a?given?view.
????????///?
????????///?The?connection?string?used?to?connect?to?the?target?database.
????????///?
????????///?
????????public?string?GetViewText(?string?connectionString?ViewSchema?view?)
????????{
????????????StringBuilder?sb?=?new?StringBuilder();
????????????string?commandText?=?string.Format(?“SELECT?VIEW_DEFINITION?FROM?INFORMATION_SCHEMA.VIEWS?WHERE?TABLE_SCHEMA?=?‘{0}‘?AN
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????52155??2017-12-07?16:35??MySQLSchemaProvider.cs
?????文件???????36864??2017-12-07?16:35??SchemaExplorer.MySQLSchemaProvider.dll
?????文件?????????164??2018-12-25?19:31??使用說明.txt
評論
共有 條評論