Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
bin
obj
/packages
/.vs
*.sqlite
26 changes: 26 additions & 0 deletions oscript-sql/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v15.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
</system.data>
</configuration>
27 changes: 13 additions & 14 deletions oscript-sql/DBConnector.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using ScriptEngine.Machine;
using ScriptEngine.HostedScript.Library;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Sql;
using ScriptEngine.Machine.Contexts;
using System.Data.SqlClient;
using System.Data.Common;
Expand All @@ -33,6 +27,9 @@ public class DBConnector : AutoContext<DBConnector>
private string _connectionString;
private string _lastErrorMessage;

/// <summary>
/// Создает новый экземпляр класса Соединение
/// </summary>
public DBConnector()
{
_dbType = 0;
Expand All @@ -46,6 +43,7 @@ public DBConnector()
_connection = null;
}

/// <inheritdoc/>
public override string ToString()
{
return "Соединение";
Expand Down Expand Up @@ -237,13 +235,10 @@ public string LastErrorMessage
}
}

public DbConnection Connection
{
get
{
return _connection;
}
}
/// <summary>
/// Соединение с БД
/// </summary>
public DbConnection Connection => _connection;

/// <summary>
/// Подготовленная строка соединения. В случае sqlite аналог ИмяБазы
Expand All @@ -263,6 +258,10 @@ public string ConnectionString
}
}

/// <summary>
/// Создать объект Соединение
/// </summary>
/// <returns>Соединение</returns>
[ScriptConstructor]
public static IRuntimeContextInstance Constructor()
{
Expand All @@ -276,7 +275,7 @@ public static IRuntimeContextInstance Constructor()
[ContextMethod("Открыть", "Open")]
public bool Open()
{
if (DbType == (new EnumDBType()).sqlite)
if (DbType == (new EnumDBType()).Sqlite)
{
if (ConnectionString == string.Empty && DbName != string.Empty)
ConnectionString = string.Format("Data Source={0};", DbName);
Expand Down
37 changes: 16 additions & 21 deletions oscript-sql/EnumDBType.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using ScriptEngine.Machine.Contexts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OScriptSql
{
Expand All @@ -13,29 +8,29 @@ namespace OScriptSql
[ContextClass("ТипСУБД", "DBType")]
public class EnumDBType : AutoContext<EnumDBType>
{
/// <summary>
/// Тип базы данных SQLite
/// </summary>
[ContextProperty("sqlite", "sqlite")]
public int sqlite
{
get { return 0; }
}
public int Sqlite => 0;

/// <summary>
/// Тип базы данных MSSQLServer
/// </summary>
[ContextProperty("MSSQLServer", "MSSQLServer")]
public int MSSQLServer
{
get { return 1; }
}
public int MSSQLServer => 1;

/// <summary>
/// Тип базы данных MySQL
/// </summary>
[ContextProperty("MySQL", "MySQL")]
public int MySQL
{
get { return 2; }
}
public int MySQL => 2;

/// <summary>
/// Тип базы данных PostgreSQL
/// </summary>
[ContextProperty("PostgreSQL", "PostgreSQL")]
public int PostgreSQL
{
get { return 3; }
}
public int PostgreSQL => 3;

}
}
8 changes: 1 addition & 7 deletions oscript-sql/IOScriptQuery.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using ScriptEngine.Machine.Contexts;
using ScriptEngine.Machine;
using ScriptEngine.Machine;
using ScriptEngine.HostedScript.Library;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OScriptSql
{
Expand Down
17 changes: 8 additions & 9 deletions oscript-sql/QueryResult.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
using System.Globalization;
using ScriptEngine.Machine.Contexts;
using ScriptEngine.Machine.Contexts;
using ScriptEngine.HostedScript.Library.ValueTable;
using ScriptEngine.Machine;
using ScriptEngine.HostedScript.Library;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SQLite;
using System.Data.Common;
using ScriptEngine.HostedScript.Library.Binary;

Expand All @@ -24,11 +17,17 @@ public class QueryResult : AutoContext<QueryResult>
{
private DbDataReader _reader;

/// <summary>
/// Создает новый экземпляр класса РезультатЗапроса.
/// </summary>
public QueryResult()
{
}


/// <summary>
/// Создает новый экземпляр класса РезультатЗапроса.
/// </summary>
/// <param name="reader">Чтение</param>
public QueryResult(DbDataReader reader)
{
_reader = reader;
Expand Down
Loading