Skip to content

Commit 7dcb5e8

Browse files
authored
Merge pull request #2 from oscript-library/dev
Dev
2 parents 5b709c8 + f710d96 commit 7dcb5e8

File tree

10 files changed

+190
-162
lines changed

10 files changed

+190
-162
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
bin
22
obj
3+
/packages
4+
/.vs
5+
*.sqlite

oscript-sql/App.config

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<configSections>
4+
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
5+
</configSections>
6+
<entityFramework>
7+
<providers>
8+
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
9+
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
10+
</providers>
11+
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
12+
<parameters>
13+
<parameter value="v15.0" />
14+
</parameters>
15+
</defaultConnectionFactory>
16+
</entityFramework>
17+
<startup>
18+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
19+
</startup>
20+
<system.data>
21+
<DbProviderFactories>
22+
<remove invariant="System.Data.SQLite.EF6" />
23+
<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" />
24+
<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>
25+
</system.data>
26+
</configuration>

oscript-sql/DBConnector.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
using ScriptEngine.Machine;
2-
using ScriptEngine.HostedScript.Library;
32

43
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Threading.Tasks;
9-
using System.Data.Sql;
104
using ScriptEngine.Machine.Contexts;
115
using System.Data.SqlClient;
126
using System.Data.Common;
@@ -33,6 +27,9 @@ public class DBConnector : AutoContext<DBConnector>
3327
private string _connectionString;
3428
private string _lastErrorMessage;
3529

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

46+
/// <inheritdoc/>
4947
public override string ToString()
5048
{
5149
return "Соединение";
@@ -237,13 +235,10 @@ public string LastErrorMessage
237235
}
238236
}
239237

240-
public DbConnection Connection
241-
{
242-
get
243-
{
244-
return _connection;
245-
}
246-
}
238+
/// <summary>
239+
/// Соединение с БД
240+
/// </summary>
241+
public DbConnection Connection => _connection;
247242

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

261+
/// <summary>
262+
/// Создать объект Соединение
263+
/// </summary>
264+
/// <returns>Соединение</returns>
266265
[ScriptConstructor]
267266
public static IRuntimeContextInstance Constructor()
268267
{
@@ -276,7 +275,7 @@ public static IRuntimeContextInstance Constructor()
276275
[ContextMethod("Открыть", "Open")]
277276
public bool Open()
278277
{
279-
if (DbType == (new EnumDBType()).sqlite)
278+
if (DbType == (new EnumDBType()).Sqlite)
280279
{
281280
if (ConnectionString == string.Empty && DbName != string.Empty)
282281
ConnectionString = string.Format("Data Source={0};", DbName);

oscript-sql/EnumDBType.cs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
using ScriptEngine.Machine.Contexts;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
72

83
namespace OScriptSql
94
{
@@ -13,29 +8,29 @@ namespace OScriptSql
138
[ContextClass("ТипСУБД", "DBType")]
149
public class EnumDBType : AutoContext<EnumDBType>
1510
{
11+
/// <summary>
12+
/// Тип базы данных SQLite
13+
/// </summary>
1614
[ContextProperty("sqlite", "sqlite")]
17-
public int sqlite
18-
{
19-
get { return 0; }
20-
}
15+
public int Sqlite => 0;
2116

17+
/// <summary>
18+
/// Тип базы данных MSSQLServer
19+
/// </summary>
2220
[ContextProperty("MSSQLServer", "MSSQLServer")]
23-
public int MSSQLServer
24-
{
25-
get { return 1; }
26-
}
21+
public int MSSQLServer => 1;
2722

23+
/// <summary>
24+
/// Тип базы данных MySQL
25+
/// </summary>
2826
[ContextProperty("MySQL", "MySQL")]
29-
public int MySQL
30-
{
31-
get { return 2; }
32-
}
27+
public int MySQL => 2;
3328

29+
/// <summary>
30+
/// Тип базы данных PostgreSQL
31+
/// </summary>
3432
[ContextProperty("PostgreSQL", "PostgreSQL")]
35-
public int PostgreSQL
36-
{
37-
get { return 3; }
38-
}
33+
public int PostgreSQL => 3;
3934

4035
}
4136
}

oscript-sql/IOScriptQuery.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
using ScriptEngine.Machine.Contexts;
2-
using ScriptEngine.Machine;
1+
using ScriptEngine.Machine;
32
using ScriptEngine.HostedScript.Library;
4-
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Threading.Tasks;
93

104
namespace OScriptSql
115
{

oscript-sql/QueryResult.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
using System.Globalization;
2-
using ScriptEngine.Machine.Contexts;
1+
using ScriptEngine.Machine.Contexts;
32
using ScriptEngine.HostedScript.Library.ValueTable;
43
using ScriptEngine.Machine;
5-
using ScriptEngine.HostedScript.Library;
64

75
using System;
8-
using System.Collections.Generic;
9-
using System.Linq;
10-
using System.Text;
11-
using System.Threading.Tasks;
12-
using System.Data.SQLite;
136
using System.Data.Common;
147
using ScriptEngine.HostedScript.Library.Binary;
158

@@ -24,11 +17,17 @@ public class QueryResult : AutoContext<QueryResult>
2417
{
2518
private DbDataReader _reader;
2619

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

31-
27+
/// <summary>
28+
/// Создает новый экземпляр класса РезультатЗапроса.
29+
/// </summary>
30+
/// <param name="reader">Чтение</param>
3231
public QueryResult(DbDataReader reader)
3332
{
3433
_reader = reader;

0 commit comments

Comments
 (0)