Skip to content

Commit d8f7245

Browse files
committed
release 1.2.4
1 parent 54e4766 commit d8f7245

File tree

18 files changed

+202
-168
lines changed

18 files changed

+202
-168
lines changed

ActiveRecord/Entity/DatabaseReader/Privates.vb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ Namespace ActiveRecord
4949
If columnsByDbNames.ContainsKey(readerColumnName) Then
5050
mi = columnsByDbNames(readerColumnName)
5151
rawValueTypeCode = Type.GetTypeCode(rawValue.GetType())
52-
If (rawValueTypeCode = Constants.StringTypeCode AndAlso mi.TrimChars.Length > 0) Then
53-
rawValue = rawValue.ToString().Trim(mi.TrimChars)
54-
ElseIf rawValueTypeCode = Type.GetTypeCode(mi.Type) Then
55-
targetValue = rawValue
56-
ElseIf mi.Type.IsEnum Then
57-
targetValue = System.[Enum].Parse(mi.Type, rawValue.ToString())
58-
Else
59-
formatProvider = If(mi.FormatProvider, System.Globalization.CultureInfo.CurrentCulture)
52+
If (rawValueTypeCode = Constants.StringTypeCode AndAlso mi.TrimChars.Length > 0) Then
53+
rawValue = rawValue.ToString().Trim(mi.TrimChars)
54+
ElseIf rawValueTypeCode = Type.GetTypeCode(mi.Type) Then
55+
targetValue = rawValue
56+
ElseIf mi.Type.IsEnum Then
57+
targetValue = System.[Enum].Parse(mi.Type, rawValue.ToString())
58+
Else
59+
formatProvider = If(mi.FormatProvider, System.Globalization.CultureInfo.CurrentCulture)
6060
targetValue = If(TypeOf rawValue Is DBNull, Nothing, Convert.ChangeType(rawValue, mi.Type, formatProvider))
6161
End If
6262
If (mi.MemberInfoType = MemberInfoType.Prop) Then

ActiveRecord/Entity/InstanceGettersSetters/Indexer.vb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Imports System.Dynamic
22
Imports System.Reflection
33
Imports System.Runtime.CompilerServices
4+
Imports System.Runtime.Serialization
45

56
Namespace ActiveRecord
67
''' <summary>
@@ -9,7 +10,7 @@ Namespace ActiveRecord
910
''' named in the same case sensitive way as columns are named in database.
1011
''' Choose fields and properties types to fit into database types.
1112
''' </summary>
12-
<DefaultMember("Item")>
13+
<DefaultMember("Item"), DataContract, Serializable>
1314
Partial Public MustInherit Class Entity
1415
Inherits DynamicObject
1516

ActiveRecord/Entity/Manipulations/Save.vb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ Namespace ActiveRecord
55
Partial Public MustInherit Class Entity
66
Inherits DynamicObject
77

8-
Public Function Save(Optional insertNew As Boolean = False) As Integer
9-
Dim connection As Connection = Connection.Get(
10-
Tools.GetConnectionIndexByClassAttr(Me.GetType(), True)
11-
)
12-
Return connection.GetProviderResource().Save(insertNew, Me, connection)
13-
End Function
8+
Public Function Save(Optional insertNew As Boolean = False) As Integer
9+
Dim connection As Connection = Connection.Get(
10+
Tools.GetConnectionIndexByClassAttr(Me.GetType(), True)
11+
)
12+
Return connection.GetProviderResource().Save(insertNew, Me, connection)
13+
End Function
1414

15-
Public Function Save(insertNew As Boolean, connection As Connection) As Integer
15+
Public Function Save(insertNew As Boolean, connection As Connection) As Integer
1616
Return connection.GetProviderResource().Save(insertNew, Me, connection)
1717
End Function
1818

Connection.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Partial Public MustInherit Class Connection
5959
''' <summary>
6060
''' Threads semahore to read/write into managed connections store.
6161
''' </summary>
62-
Private Shared _staticInitDoneLock As New Object
62+
Private Shared _staticInitDoneLock As New ReaderWriterLockSlim
6363
''' <summary>
6464
''' True if static initialization completed, nothing else.
6565
''' </summary>

Connection/BeginTransaction.vb

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,45 @@
22

33
Partial Public MustInherit Class Connection
44

5-
''' <summary>
6-
''' Create and begin transaction on first config connection.
7-
''' </summary>
8-
''' <param name="transactionName">Transaction name.</param>
9-
''' <param name="isolationLevel">Transaction isolation level.</param>
10-
''' <returns>New transaction.</returns>
11-
Public Function BeginTransaction(transactionName As String, isolationLevel As IsolationLevel) As Transaction
12-
Return Me.createAndBeginTransaction(
13-
transactionName, isolationLevel
14-
)
15-
End Function
5+
''' <summary>
6+
''' Create and begin transaction on first config connection.
7+
''' </summary>
8+
''' <param name="transactionName">Transaction name.</param>
9+
''' <param name="isolationLevel">Transaction isolation level.</param>
10+
''' <returns>New transaction.</returns>
11+
Public Function BeginTransaction(transactionName As String, isolationLevel As IsolationLevel) As Transaction
12+
Return Me.createAndBeginTransaction(
13+
transactionName, isolationLevel
14+
)
15+
End Function
1616

17-
''' <summary>
18-
''' Create and begin transaction on specified connection config index.
19-
''' </summary>
20-
''' <param name="connectionIndex">Config connection index.</param>
21-
''' <param name="transactionName">Transaction name.</param>
22-
''' <param name="isolationLevel">Transaction isolation level.</param>
23-
''' <returns>New transaction.</returns>
24-
Public Shared Function BeginTransaction(connectionIndex As Int32, Optional transactionName As String = "", Optional isolationLevel As IsolationLevel = IsolationLevel.Unspecified) As Transaction
25-
Return Databasic.Connection.Get(connectionIndex).createAndBeginTransaction(
26-
transactionName, isolationLevel
27-
)
28-
End Function
17+
''' <summary>
18+
''' Create and begin transaction on specified connection config index.
19+
''' </summary>
20+
''' <param name="connectionIndex">Config connection index.</param>
21+
''' <param name="transactionName">Transaction name.</param>
22+
''' <param name="isolationLevel">Transaction isolation level.</param>
23+
''' <returns>New transaction.</returns>
24+
Public Shared Function BeginTransaction(connectionIndex As Int32, Optional transactionName As String = "", Optional isolationLevel As IsolationLevel = IsolationLevel.Unspecified) As Transaction
25+
Return Databasic.Connection.Get(connectionIndex).createAndBeginTransaction(
26+
transactionName, isolationLevel
27+
)
28+
End Function
2929

30-
''' <summary>
31-
''' Create and begin transaction on specified connection config name.
32-
''' </summary>
33-
''' <param name="connectionName">Config connection name.</param>
34-
''' <param name="transactionName">Transaction name.</param>
35-
''' <param name="isolationLevel">Transaction isolation level.</param>
36-
''' <returns>New transaction.</returns>
37-
Public Shared Function BeginTransaction(connectionName As String, Optional transactionName As String = "", Optional isolationLevel As IsolationLevel = IsolationLevel.Unspecified) As Transaction
38-
Return Databasic.Connection.Get(connectionName).createAndBeginTransaction(
39-
transactionName, isolationLevel
40-
)
41-
End Function
30+
''' <summary>
31+
''' Create and begin transaction on specified connection config name.
32+
''' </summary>
33+
''' <param name="connectionName">Config connection name.</param>
34+
''' <param name="transactionName">Transaction name.</param>
35+
''' <param name="isolationLevel">Transaction isolation level.</param>
36+
''' <returns>New transaction.</returns>
37+
Public Shared Function BeginTransaction(connectionName As String, Optional transactionName As String = "", Optional isolationLevel As IsolationLevel = IsolationLevel.Unspecified) As Transaction
38+
Return Databasic.Connection.Get(connectionName).createAndBeginTransaction(
39+
transactionName, isolationLevel
40+
)
41+
End Function
4242

43-
Protected Overridable Function createAndBeginTransaction(Optional transactionName As String = "", Optional isolationLevel As IsolationLevel = -1) As Transaction
43+
Protected Overridable Function createAndBeginTransaction(Optional transactionName As String = "", Optional isolationLevel As IsolationLevel = -1) As Transaction
4444
Return Nothing
4545
End Function
4646

Connection/StaticInit.vb

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Imports System.Threading
66
Imports Databasic
77

88
Partial Public MustInherit Class Connection
9+
10+
Private Const _DATABASIC_ASM_NAME As String = "Databasic"
11+
Private Const _DATABASIC_ASM_NAME_BEGIN As String = "Databasic."
912
''' <summary>
1013
''' Load config and set up connection strings.
1114
''' </summary>
@@ -43,30 +46,32 @@ Partial Public MustInherit Class Connection
4346
End Sub
4447

4548
Private Shared Sub _staticInitCompleteProviders()
46-
Dim result As New Dictionary(Of String, Type)
47-
Try
48-
Dim assemblyFolder As String = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
49-
Dim assemblyNeighbours As IEnumerable(Of Assembly) = (
50-
From file In Directory.GetFiles(assemblyFolder)
51-
Where Path.GetExtension(file).ToLower() = ".dll"
52-
Select Assembly.LoadFrom(file)
53-
)
54-
Dim assemblyName As String
55-
Dim connectionType As Type
56-
Dim connection As Connection
57-
For Each assembly As Reflection.Assembly In assemblyNeighbours
58-
assemblyName = assembly.GetName().Name
59-
If assemblyName.IndexOf("Databasic.") = 0 AndAlso assemblyName <> "Databasic" Then
60-
connectionType = assembly.GetType(assemblyName + ".Connection")
61-
If Not TypeOf connectionType Is Type Then Continue For
62-
connection = Activator.CreateInstance(connectionType)
63-
Connection._supportedProviders.Add(connection.ClientName, connectionType)
64-
Connection._providersResources.Add(connection.ClientName, Activator.CreateInstance(connection.ProviderResource))
65-
End If
66-
Next
67-
Catch ex As Exception
68-
Events.RaiseError(ex)
69-
End Try
49+
Dim asms As New Dictionary(Of String, Reflection.Assembly)
50+
Dim asmName As String
51+
Dim connectionType As Type
52+
Dim conn As Connection
53+
Dim referencedAsms As Reflection.Assembly() = AppDomain.CurrentDomain.GetAssemblies()
54+
For Each asm As Reflection.Assembly In referencedAsms
55+
If Connection._staticInitIsDatabasicSubAssembly(asm) Then
56+
asmName = asm.GetName().Name
57+
connectionType = asm.GetType(asmName + ".Connection")
58+
If Not TypeOf connectionType Is Type Then Continue For
59+
conn = Activator.CreateInstance(connectionType)
60+
Connection._supportedProviders.Add(conn.ClientName, connectionType)
61+
Connection._providersResources.Add(
62+
conn.ClientName, Activator.CreateInstance(conn.ProviderResource)
63+
)
64+
End If
65+
Next
7066
End Sub
7167

68+
Private Shared Function _staticInitIsDatabasicSubAssembly(asm As Reflection.Assembly) As Boolean
69+
Dim asmName As String = asm.GetName().Name
70+
If (
71+
asmName.IndexOf(Connection._DATABASIC_ASM_NAME_BEGIN) = 0 And
72+
asmName <> Connection._DATABASIC_ASM_NAME
73+
) Then Return True
74+
Return False
75+
End Function
76+
7277
End Class

Databasic.nuspec

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
33
<metadata minClientVersion="2.6">
4-
<id>Databasic.Core</id>
5-
<version>1.2.0.0</version>
6-
<title>Databasic - Core Package</title>
7-
<authors>Tom Flidr</authors>
8-
<owners>Tom Flidr</owners>
9-
<licenseUrl>https://opensource.org/licenses/BSD-3-Clause</licenseUrl>
10-
<projectUrl>https://github.com/databasic-net</projectUrl>
11-
<iconUrl>https://raw.githubusercontent.com/databasic-net/databasic/master/gfx/databasic-icon.ico</iconUrl>
12-
<language>en-US</language>
13-
<requireLicenseAcceptance>false</requireLicenseAcceptance>
14-
<description>
15-
C#/VB.NET database utility to write pure Microsoft SQL/MySQL/PgSql/Oracle/SQLite queries and load data into environment variables and instances.
16-
This is core package only. Install this package only by installing specific database package like: Databasic.&#60;DatabaseType&#62;. Then this package will be installed automaticly with the specific database package.
17-
</description>
18-
<copyright>Copyright © 2017</copyright>
19-
<tags>microsoft sql mssql postgres oracle sqlite tsql mssql database query command select insert update delete dml tool utility</tags>
20-
<dependencies>
21-
<!--dependency id="System" version="4.0.0.0" />
22-
<dependency id="System.Core" version="4.0.0.0" />
23-
<dependency id="System.Data" version="4.0.0.0" />
24-
<dependency id="System.Configuration" version="4.0.0.0" /-->
25-
</dependencies>
26-
<releaseNotes>https://github.com/databasic-net/databasic/releases</releaseNotes>
4+
<id>Databasic.Core</id>
5+
<version>1.2.4.0</version>
6+
<title>Databasic - Core Package</title>
7+
<authors>Tom Flidr</authors>
8+
<owners>Tom Flidr</owners>
9+
<licenseUrl>https://opensource.org/licenses/BSD-3-Clause</licenseUrl>
10+
<projectUrl>https://github.com/databasic-net</projectUrl>
11+
<iconUrl>https://raw.githubusercontent.com/databasic-net/databasic/master/gfx/databasic-icon.ico</iconUrl>
12+
<language>en-US</language>
13+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
14+
<description>
15+
C#/VB.NET database utility to write pure Microsoft SQL/MySQL/PgSql/Oracle/SQLite queries and load data into environment variables and instances.
16+
This is core package only. Install this package only by installing specific database package like: Databasic.&#60;DatabaseType&#62;. Then this package will be installed automaticly with the specific database package.
17+
</description>
18+
<copyright>Copyright © 2017</copyright>
19+
<tags>microsoft sql mssql postgres oracle sqlite tsql mssql database query command select insert update delete dml tool utility</tags>
20+
<dependencies>
21+
<!--dependency id="System" version="4.0.0.0" />
22+
<dependency id="System.Core" version="4.0.0.0" />
23+
<dependency id="System.Data" version="4.0.0.0" />
24+
<dependency id="System.Configuration" version="4.0.0.0" /-->
25+
</dependencies>
26+
<releaseNotes>https://github.com/databasic-net/databasic/releases</releaseNotes>
2727
</metadata>
2828
</package>

Databasic.vbproj

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,19 @@
4343
<PropertyGroup>
4444
<OptionInfer>On</OptionInfer>
4545
</PropertyGroup>
46+
<PropertyGroup>
47+
<SignAssembly>false</SignAssembly>
48+
</PropertyGroup>
49+
<PropertyGroup>
50+
<AssemblyOriginatorKeyFile>
51+
</AssemblyOriginatorKeyFile>
52+
</PropertyGroup>
4653
<ItemGroup>
4754
<Reference Include="System" />
4855
<Reference Include="System.Configuration" />
4956
<Reference Include="System.Core" />
5057
<Reference Include="System.Data" />
58+
<Reference Include="System.Runtime.Serialization" />
5159
<Reference Include="System.Web" />
5260
</ItemGroup>
5361
<ItemGroup>
@@ -164,7 +172,18 @@
164172
<PostBuildEvent>REM Create a NuGet package for this project and place the .nupkg file in the project's output directory.
165173
REM If you see this in Visual Studio's Error List window, check the Output window's Build tab for the actual error.
166174
ECHO Creating NuGet package in Post-Build event...
167-
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "&amp; '$(ProjectDir)_CreateNewNuGetPackage\DoNotModify\CreateNuGetPackage.ps1' -ProjectFilePath '$(ProjectPath)' -OutputDirectory '$(TargetDir)' -BuildConfiguration '$(ConfigurationName)' -BuildPlatform '$(PlatformName)'"</PostBuildEvent>
175+
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "&amp; '$(ProjectDir)_CreateNewNuGetPackage\DoNotModify\CreateNuGetPackage.ps1' -ProjectFilePath '$(ProjectPath)' -OutputDirectory '$(TargetDir)' -BuildConfiguration '$(ConfigurationName)' -BuildPlatform '$(PlatformName)'"
176+
177+
@set wd=%25cd%25
178+
@cd ../../../Databasic.BuildCommands
179+
@cscript.exe PostBuild.wsf "%25wd%25"
180+
@cd %25wd%25</PostBuildEvent>
181+
</PropertyGroup>
182+
<PropertyGroup>
183+
<PreBuildEvent>@set wd=%25cd%25
184+
@cd ../../../Databasic.BuildCommands
185+
@cscript.exe ./PreBuild.wsf
186+
@cd %25wd%25</PreBuildEvent>
168187
</PropertyGroup>
169188
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
170189
Other similar extension points exist, see Microsoft.Common.targets.

MetaDescriptor.vb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,21 @@ Public Class MetaDescriptor
229229
End If
230230
formatProvider = If(TypeOf formatAttr Is FormatAttribute, formatAttr.FormatProvider, Nothing)
231231
trimChars = If(TypeOf trimAttr Is TrimAttribute, trimAttr.Chars, New Char() {})
232-
' complete code column names and db column names collections
233-
result.ColumnsByCodeNames.Add(codeColumnName, New Databasic.MemberInfo With {
234-
.Name = dbColumnName,
235-
.MemberInfo = reflMemberInfo, .Type = item.Value.Type,
236-
.FormatProvider = formatProvider, .TrimChars = trimChars,
237-
.MemberInfoType = item.Value.MemberInfoType, .Value = Nothing
238-
})
239-
result.ColumnsByDatabaseNames.Add(dbColumnName, New Databasic.MemberInfo With {
240-
.Name = codeColumnName,
241-
.MemberInfo = reflMemberInfo, .Type = item.Value.Type,
242-
.FormatProvider = formatProvider, .TrimChars = trimChars,
243-
.MemberInfoType = item.Value.MemberInfoType, .Value = Nothing
244-
})
245-
' if there is any key info at class element, add it into keys info collections
246-
If TypeOf primaryKeyAttr Is PrimaryKeyAttribute Then
232+
' complete code column names and db column names collections
233+
result.ColumnsByCodeNames.Add(codeColumnName, New Databasic.MemberInfo With {
234+
.Name = dbColumnName,
235+
.MemberInfo = reflMemberInfo, .Type = item.Value.Type,
236+
.FormatProvider = formatProvider, .TrimChars = trimChars,
237+
.MemberInfoType = item.Value.MemberInfoType, .Value = Nothing
238+
})
239+
result.ColumnsByDatabaseNames.Add(dbColumnName, New Databasic.MemberInfo With {
240+
.Name = codeColumnName,
241+
.MemberInfo = reflMemberInfo, .Type = item.Value.Type,
242+
.FormatProvider = formatProvider, .TrimChars = trimChars,
243+
.MemberInfoType = item.Value.MemberInfoType, .Value = Nothing
244+
})
245+
' if there is any key info at class element, add it into keys info collections
246+
If TypeOf primaryKeyAttr Is PrimaryKeyAttribute Then
247247
If Not String.IsNullOrEmpty(primaryKeyAttr.KeyName) Then keyName = primaryKeyAttr.KeyName
248248
If result.PrimaryColumns.ContainsKey(keyName) Then
249249
result.PrimaryColumns(keyName).Add(codeColumnName, dbColumnName)

Misc/Enums.vb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ Public Enum ProviderName
4949
''' <summary>
5050
''' ODBC server - System.Data.Odbc
5151
''' </summary>
52-
ODBC
52+
OdbcSql
5353
''' <summary>
54-
''' Oracle server - Oracle.DataAccess.Client
54+
''' ODBC server - System.Data.Odbc
55+
''' </summary>
56+
OleSql
57+
''' <summary>
58+
''' OLE database or server - Oracle.DataAccess.Client
5559
''' </summary>
5660
OracleSql
5761
''' <summary>

0 commit comments

Comments
 (0)