Browse files

Started adding support for RavenDB

  • Loading branch information...
1 parent 46f3d00 commit 22269fed4d3ec802421ffcec25f74c5d937c3a6b Hans Olav Loftum committed Feb 19, 2012
Showing with 35,953 additions and 31 deletions.
  1. +5 −5 DbTool/DbTool.Lib/CSharp/Mono/DbToolInteractive.cs
  2. +48 −0 DbTool/DbTool.Lib/Communication/DbCommands/Dynamic/DynamicQuery.cs
  3. +0 −1 DbTool/DbTool.Lib/Communication/DbCommands/Dynamic/DynamicSqlQuery.cs
  4. +30 −18 DbTool/DbTool.Lib/Configuration/ConnectionData.cs
  5. +1 −0 DbTool/DbTool.Lib/Configuration/DbToolContext.cs
  6. +7 −0 DbTool/DbTool.Lib/Configuration/DbToolDatabase.cs
  7. +17 −1 DbTool/DbTool.Lib/DbTool.Lib.csproj
  8. +2 −1 DbTool/DbTool.Lib/{DatabaseType.cs → DbType.cs}
  9. +1 −1 DbTool/DbTool.Lib/Migrating/MigSharpRunner.cs
  10. +10 −4 DbTool/DbToolGui/Controls/Syntax/EditorTextBox.xaml.cs
  11. BIN Lib/3rdParty/RavenDB-Build-616/Client/AsyncCtpLibrary.dll
  12. +2,341 −0 Lib/3rdParty/RavenDB-Build-616/Client/AsyncCtpLibrary.xml
  13. BIN Lib/3rdParty/RavenDB-Build-616/Client/NLog.dll
  14. +14,353 −0 Lib/3rdParty/RavenDB-Build-616/Client/NLog.xml
  15. BIN Lib/3rdParty/RavenDB-Build-616/Client/Newtonsoft.Json.dll
  16. BIN Lib/3rdParty/RavenDB-Build-616/Client/Newtonsoft.Json.pdb
  17. +7,141 −0 Lib/3rdParty/RavenDB-Build-616/Client/Newtonsoft.Json.xml
  18. +2,505 −0 Lib/3rdParty/RavenDB-Build-616/Client/Raven.Abstractions.XML
  19. BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Abstractions.dll
  20. BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Abstractions.pdb
  21. BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.Debug.dll
  22. BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.Debug.pdb
  23. +9,492 −0 Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.Lightweight.XML
  24. BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.Lightweight.dll
  25. BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.Lightweight.pdb
  26. BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.MvcIntegration.dll
  27. BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.MvcIntegration.pdb
View
10 DbTool/DbTool.Lib/CSharp/Mono/DbToolInteractive.cs
@@ -9,29 +9,29 @@ namespace DbTool.Lib.CSharp.Mono
{
public class DbToolInteractive
{
- private static readonly DynamicSqlQuery DynamicSql = new DynamicSqlQuery();
+ private static readonly DynamicQuery DynamicQuery = new DynamicQuery();
public static Evaluator Evaluator;
public static TextWriter Output = new StringWriter();
public static IEnumerable<dynamic> Schema(string collection)
{
- return DynamicSql.Schema(collection);
+ return DynamicQuery.Schema(collection);
}
public static IEnumerable<dynamic> Query(string sql)
{
- return DynamicSql.Query(sql);
+ return DynamicQuery.Query(sql);
}
public static void SetDb(DbToolDatabase db)
{
- DynamicSql.ConnectionData = db.GetConnectionData();
+ DynamicQuery.ConnectionData = db.GetConnectionData();
}
public static void SetConnection(DbConnection connection)
{
- DynamicSql.DbConnection = connection;
+ DynamicQuery.DbConnection = connection;
}
public static string vars
View
48 DbTool/DbTool.Lib/Communication/DbCommands/Dynamic/DynamicQuery.cs
@@ -0,0 +1,48 @@
+using System.Collections.Generic;
+using System.Data.Common;
+using DbTool.Lib.Configuration;
+
+namespace DbTool.Lib.Communication.DbCommands.Dynamic
+{
+ public class DynamicQuery
+ {
+ private ConnectionData _connectionData;
+ public ConnectionData ConnectionData
+ {
+ get { return _connectionData; }
+ set
+ {
+ _connectionData = value;
+ _sqlQuery.ConnectionData = _connectionData;
+ }
+ }
+
+ private DbConnection _dbConnection;
+ public DbConnection DbConnection
+ {
+ get { return _dbConnection; }
+ set
+ {
+ _dbConnection = value;
+ _sqlQuery.DbConnection = _dbConnection;
+ }
+ }
+
+ private readonly DynamicSqlQuery _sqlQuery;
+
+ public DynamicQuery()
+ {
+ _sqlQuery = new DynamicSqlQuery();
+ }
+
+ public IEnumerable<dynamic> Schema(string collection)
+ {
+ return _sqlQuery.Schema(collection);
+ }
+
+ public IEnumerable<dynamic> Query(string sql)
+ {
+ return _sqlQuery.Query(sql);
+ }
+ }
+}
View
1 DbTool/DbTool.Lib/Communication/DbCommands/Dynamic/DynamicSqlQuery.cs
@@ -11,7 +11,6 @@ public class DynamicSqlQuery
{
public ConnectionData ConnectionData { get; set; }
public DbConnection DbConnection { get; set; }
-
public IEnumerable<dynamic> Schema(string collection)
{
View
48 DbTool/DbTool.Lib/Configuration/ConnectionData.cs
@@ -11,9 +11,11 @@ public string ProviderName
{
switch (DatabaseType)
{
- case "sqlserver":
+ case DbType.SqlServer:
+ case DbType.SqlServer2005:
+ case DbType.SqlServer2008:
return "System.Data.SqlClient";
- case "mysql":
+ case DbType.MySql:
return "MySql.Data.MySqlClient";
default:
return "System.Data.SqlClient";
@@ -30,19 +32,42 @@ public bool HasConnectionString
public string Database { get; set; }
public string DatabaseType { get; set; }
public string Host { get; set; }
+ public int Port { get; set; }
public DbToolCredentials Credentials { get; set; }
- public string GetConnectionString(bool includeDatabase = true)
+ public string GetConnectionString()
{
switch(DatabaseType)
{
- case "mysql":
- return GetConnectionStringForMySql();
+ case DbType.RavenDB:
+ return GetRavenConnectionString();
default:
return GetDefaultConnectionString();
}
}
+ private string GetRavenConnectionString()
+ {
+ var elements = new List<string>();
+ elements.Add(string.Format("Url={0}", GetHttpHostAndPort()));
+ if (Database.IsNotNullOrEmpty())
+ {
+ elements.Add(string.Format("Database={0}", Database));
+ }
+ if (Credentials.User.IsNotNullOrEmpty())
+ {
+ elements.Add(string.Format("User={0}", Credentials.User));
+ elements.Add(string.Format("Password={0}", Credentials.Password));
+ }
+ return string.Join(";", elements);
+ }
+
+ private string GetHttpHostAndPort()
+ {
+ var host = Host.StartsWith("http://") ? Host : string.Format("http://{0}", Host);
+ return Port > 0 ? string.Format("{0}:{1}", host, Port) : host;
+ }
+
private string GetDefaultConnectionString()
{
var elements = new List<string>();
@@ -62,18 +87,5 @@ private string GetDefaultConnectionString()
}
return string.Join(";", elements);
}
-
- private string GetConnectionStringForMySql()
- {
- var elements = new List<string>();
- elements.Add(string.Format("Server={0}", Host));
- if (Database.IsNotNullOrEmpty())
- {
- elements.Add(string.Format("Database={0}", Database));
- }
- elements.Add(string.Format("Uid={0}", Credentials.User));
- elements.Add(string.Format("Pwd={0}", Credentials.Password));
- return string.Join(";", elements);
- }
}
}
View
1 DbTool/DbTool.Lib/Configuration/DbToolContext.cs
@@ -11,6 +11,7 @@ public class DbToolContext
public string Name { get; set; }
public string DatabaseType { get; set; }
public string Host { get; set; }
+ public int Port { get; set; }
public DbToolCredentials Credentials { get; set; }
public IList<DbToolDatabase> Databases { get; set; }
[JsonIgnore]
View
7 DbTool/DbTool.Lib/Configuration/DbToolDatabase.cs
@@ -31,6 +31,13 @@ public string Host
set { _host = value; }
}
+ private int _port;
+ public int Port
+ {
+ get { return _port > 0 ? _port : FromParentOrDefault(p => p.Port); }
+ set { _port = value; }
+ }
+
private DbToolCredentials _credentials;
public DbToolCredentials Credentials
{
View
18 DbTool/DbTool.Lib/DbTool.Lib.csproj
@@ -30,6 +30,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="AsyncCtpLibrary">
+ <HintPath>..\..\Lib\3rdParty\RavenDB-Build-616\Client\AsyncCtpLibrary.dll</HintPath>
+ </Reference>
<Reference Include="Migrator">
<HintPath>..\BuildAssets\Migrator\Migrator.dll</HintPath>
</Reference>
@@ -51,6 +54,18 @@
<Reference Include="Ninject">
<HintPath>..\..\Lib\3rdParty\Ninject-2.2.0.0-release-net-4.0\Ninject.dll</HintPath>
</Reference>
+ <Reference Include="NLog">
+ <HintPath>..\..\Lib\3rdParty\RavenDB-Build-616\Client\NLog.dll</HintPath>
+ </Reference>
+ <Reference Include="Raven.Abstractions">
+ <HintPath>..\..\Lib\3rdParty\RavenDB-Build-616\Client\Raven.Abstractions.dll</HintPath>
+ </Reference>
+ <Reference Include="Raven.Client.Debug">
+ <HintPath>..\..\Lib\3rdParty\RavenDB-Build-616\Client\Raven.Client.Debug.dll</HintPath>
+ </Reference>
+ <Reference Include="Raven.Client.Lightweight">
+ <HintPath>..\..\Lib\3rdParty\RavenDB-Build-616\Client\Raven.Client.Lightweight.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -79,6 +94,7 @@
<Compile Include="Communication\DbCommands\Dynamic\ClassGenerator.cs" />
<Compile Include="Communication\DbCommands\Dynamic\DynamicDataRow.cs" />
<Compile Include="Communication\DbCommands\Dynamic\DynamicDataRowPropertyDescriptor.cs" />
+ <Compile Include="Communication\DbCommands\Dynamic\DynamicQuery.cs" />
<Compile Include="Communication\DbCommands\Dynamic\DynamicSqlQuery.cs" />
<Compile Include="Communication\DbCommands\IDbCommandExecutor.cs" />
<Compile Include="Communication\DbCommands\IExecutorProvider.cs" />
@@ -113,7 +129,7 @@
<Compile Include="CSharp\ICSharpEvaluator.cs" />
<Compile Include="CSharp\Mono\DbToolInteractive.cs" />
<Compile Include="CSharp\Mono\MonoCSharpEvaluator.cs" />
- <Compile Include="DatabaseType.cs" />
+ <Compile Include="DbType.cs" />
<Compile Include="Data\ColumnDescriptor.cs" />
<Compile Include="Data\Property.cs" />
<Compile Include="Data\Record.cs" />
View
3 DbTool/DbTool.Lib/DatabaseType.cs → DbTool/DbTool.Lib/DbType.cs
@@ -3,8 +3,9 @@
namespace DbTool.Lib
{
- public class DatabaseType
+ public class DbType
{
+ public const string RavenDB = "ravendb";
public const string SqlServer = "sqlserver";
public const string SqlServer2005 = "sqlserver2005";
public const string SqlServer2008 = "sqlserver2008";
View
2 DbTool/DbTool.Lib/Migrating/MigSharpRunner.cs
@@ -27,7 +27,7 @@ public void MigrateToLatest()
private MigSharp.Migrator CreateMigrator()
{
- var providerName = DatabaseType.ToMigSharpProvider(_database.DatabaseType);
+ var providerName = DbType.ToMigSharpProvider(_database.DatabaseType);
var connection = _database.GetConnectionData();
var options = new MigrationOptions();
options.SupportedProviders.Set(providerName.AsArray());
View
14 DbTool/DbToolGui/Controls/Syntax/EditorTextBox.xaml.cs
@@ -197,14 +197,16 @@ protected override void OnPreviewKeyDown(KeyEventArgs e)
if (SelectedText != string.Empty)
{
string[] lines = SelectedText.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
- for (int i = 0; i < lines.Length; i++)
+ for (int ii = 0; ii < lines.Length; ii++)
{
- if (lines[i].StartsWith(Tab))
+ if (lines[ii].StartsWith(Tab))
{
- lines[i] = lines[i].Substring(Tab.Length);
+ lines[ii] = lines[ii].Substring(Tab.Length);
}
else
- lines[i] = lines[i].TrimStart(' ');
+ {
+ lines[ii] = lines[ii].TrimStart(' ');
+ }
}
SelectedText = String.Join(Environment.NewLine, lines);
}
@@ -221,9 +223,13 @@ protected override void OnPreviewKeyDown(KeyEventArgs e)
var startLine = Text.IndexOf(Environment.NewLine, lastLine, StringComparison.Ordinal);
if (startLine != -1)
+ {
startLine += Environment.NewLine.Length;
+ }
else
+ {
startLine = 0;
+ }
// find empty spaces
var spaces = 0;
View
BIN Lib/3rdParty/RavenDB-Build-616/Client/AsyncCtpLibrary.dll
Binary file not shown.
View
2,341 Lib/3rdParty/RavenDB-Build-616/Client/AsyncCtpLibrary.xml
2,341 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
BIN Lib/3rdParty/RavenDB-Build-616/Client/NLog.dll
Binary file not shown.
View
14,353 Lib/3rdParty/RavenDB-Build-616/Client/NLog.xml
14,353 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
BIN Lib/3rdParty/RavenDB-Build-616/Client/Newtonsoft.Json.dll
Binary file not shown.
View
BIN Lib/3rdParty/RavenDB-Build-616/Client/Newtonsoft.Json.pdb
Binary file not shown.
View
7,141 Lib/3rdParty/RavenDB-Build-616/Client/Newtonsoft.Json.xml
7,141 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2,505 Lib/3rdParty/RavenDB-Build-616/Client/Raven.Abstractions.XML
2,505 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Abstractions.dll
Binary file not shown.
View
BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Abstractions.pdb
Binary file not shown.
View
BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.Debug.dll
Binary file not shown.
View
BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.Debug.pdb
Binary file not shown.
View
9,492 Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.Lightweight.XML
9,492 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.Lightweight.dll
Binary file not shown.
View
BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.Lightweight.pdb
Binary file not shown.
View
BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.MvcIntegration.dll
Binary file not shown.
View
BIN Lib/3rdParty/RavenDB-Build-616/Client/Raven.Client.MvcIntegration.pdb
Binary file not shown.

0 comments on commit 22269fe

Please sign in to comment.