Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 61a99a4

Browse files
committed
Merge pull request #394 from ilyalukyanov/master
Added VistaDB4 and VistaDB5 support
2 parents 230a7a2 + 3db90a0 commit 61a99a4

File tree

77 files changed

+9434
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+9434
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace ServiceStack.OrmLite.VistaDB
8+
{
9+
public class OrmLiteVistaDbCommand : IDbCommand
10+
{
11+
public IDbCommand VistaDbCommand { get; private set; }
12+
13+
private OrmLiteVistaDbConnection _connectionWrapper;
14+
private OrmLiteVistaDbTransaction _transactionWrapper;
15+
16+
public OrmLiteVistaDbCommand(OrmLiteVistaDbConnection connectionWrapper, IDbCommand vistaDbCommand)
17+
{
18+
if (connectionWrapper == null)
19+
throw new ArgumentNullException("connectionWrapper");
20+
21+
if (vistaDbCommand == null)
22+
throw new ArgumentNullException("vistaDbCommand");
23+
24+
_connectionWrapper = connectionWrapper;
25+
26+
this.VistaDbCommand = vistaDbCommand;
27+
this.Parameters = new OrmLiteVistaDbParameterCollection(vistaDbCommand.Parameters);
28+
}
29+
30+
#region IDbCommand Members
31+
32+
public void Cancel()
33+
{
34+
this.VistaDbCommand.Cancel();
35+
}
36+
37+
public string CommandText
38+
{
39+
get { return this.VistaDbCommand.CommandText; }
40+
set { this.VistaDbCommand.CommandText = value; }
41+
}
42+
43+
public int CommandTimeout
44+
{
45+
get { return this.VistaDbCommand.CommandTimeout; }
46+
set { this.VistaDbCommand.CommandTimeout = value; }
47+
}
48+
49+
public CommandType CommandType
50+
{
51+
get { return this.VistaDbCommand.CommandType; }
52+
set { this.VistaDbCommand.CommandType = value; }
53+
}
54+
55+
public IDbConnection Connection
56+
{
57+
get { return _connectionWrapper; }
58+
set
59+
{
60+
_connectionWrapper = (OrmLiteVistaDbConnection)value;
61+
this.VistaDbCommand.Connection = _connectionWrapper.VistaDbConnection;
62+
}
63+
}
64+
65+
public IDbDataParameter CreateParameter()
66+
{
67+
var vistaDbParameter = this.VistaDbCommand.CreateParameter();
68+
69+
return new OrmLiteVistaDbParameter(vistaDbParameter);
70+
}
71+
72+
public int ExecuteNonQuery()
73+
{
74+
return this.VistaDbCommand.ExecuteNonQuery();
75+
}
76+
77+
public IDataReader ExecuteReader(CommandBehavior behavior)
78+
{
79+
return this.VistaDbCommand.ExecuteReader(behavior);
80+
}
81+
82+
public IDataReader ExecuteReader()
83+
{
84+
return this.VistaDbCommand.ExecuteReader();
85+
}
86+
87+
public object ExecuteScalar()
88+
{
89+
return this.VistaDbCommand.ExecuteScalar();
90+
}
91+
92+
public IDataParameterCollection Parameters { get; private set; }
93+
94+
public void Prepare()
95+
{
96+
this.VistaDbCommand.Prepare();
97+
}
98+
99+
public IDbTransaction Transaction
100+
{
101+
get
102+
{
103+
return _transactionWrapper;
104+
}
105+
set
106+
{
107+
_transactionWrapper = (OrmLiteVistaDbTransaction)value;
108+
109+
if (_transactionWrapper != null)
110+
this.VistaDbCommand.Transaction = _transactionWrapper.VistaDbTransaction;
111+
}
112+
}
113+
114+
public UpdateRowSource UpdatedRowSource
115+
{
116+
get { return this.VistaDbCommand.UpdatedRowSource; }
117+
set { this.VistaDbCommand.UpdatedRowSource = value; }
118+
}
119+
120+
#endregion
121+
122+
#region IDisposable Members
123+
124+
public void Dispose()
125+
{
126+
this.VistaDbCommand.Dispose();
127+
}
128+
129+
#endregion
130+
}
131+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace ServiceStack.OrmLite.VistaDB
8+
{
9+
public class OrmLiteVistaDbConnection : IDbConnection, ICloneable
10+
{
11+
public IDbConnection VistaDbConnection { get; private set; }
12+
13+
public OrmLiteVistaDbConnection(IDbConnection conn)
14+
{
15+
if (conn == null)
16+
throw new ArgumentNullException("conn");
17+
18+
VistaDbConnection = conn;
19+
}
20+
21+
#region IDbConnection Members
22+
23+
public IDbTransaction BeginTransaction(IsolationLevel il)
24+
{
25+
//VistaDB 4 supports only ReadCommited isolation level
26+
if (il != IsolationLevel.Unspecified && il != IsolationLevel.ReadCommitted)
27+
il = IsolationLevel.ReadCommitted;
28+
29+
var tn = VistaDbConnection.BeginTransaction(il);
30+
return new OrmLiteVistaDbTransaction(this, tn);
31+
}
32+
33+
public IDbTransaction BeginTransaction()
34+
{
35+
var tn = this.VistaDbConnection.BeginTransaction();
36+
37+
return new OrmLiteVistaDbTransaction(this, tn);
38+
}
39+
40+
public void ChangeDatabase(string databaseName)
41+
{
42+
VistaDbConnection.ChangeDatabase(databaseName);
43+
}
44+
45+
public void Close()
46+
{
47+
VistaDbConnection.Close();
48+
}
49+
50+
public string ConnectionString
51+
{
52+
get { return VistaDbConnection.ConnectionString; }
53+
set { VistaDbConnection.ConnectionString = value; }
54+
}
55+
56+
public int ConnectionTimeout
57+
{
58+
get { return VistaDbConnection.ConnectionTimeout; }
59+
}
60+
61+
public IDbCommand CreateCommand()
62+
{
63+
var cmd = VistaDbConnection.CreateCommand();
64+
65+
return new OrmLiteVistaDbCommand(this, cmd);
66+
}
67+
68+
public string Database
69+
{
70+
get { return VistaDbConnection.Database; }
71+
}
72+
73+
public void Open()
74+
{
75+
VistaDbConnection.Open();
76+
}
77+
78+
public ConnectionState State
79+
{
80+
get { return VistaDbConnection.State; }
81+
}
82+
83+
#endregion
84+
85+
#region IDisposable Members
86+
87+
public void Dispose()
88+
{
89+
VistaDbConnection.Dispose();
90+
}
91+
92+
#endregion
93+
94+
#region ICloneable Members
95+
96+
public object Clone()
97+
{
98+
var cloneable = (ICloneable) VistaDbConnection;
99+
var conn = (IDbConnection) cloneable.Clone();
100+
101+
return new OrmLiteVistaDbConnection(conn);
102+
}
103+
104+
#endregion
105+
}
106+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace ServiceStack.OrmLite.VistaDB
8+
{
9+
public class OrmLiteVistaDbParameter : IDbDataParameter
10+
{
11+
private object _backgroundValue;
12+
13+
public IDbDataParameter VistaDbParameter { get; private set; }
14+
15+
internal OrmLiteVistaDbParameter(IDbDataParameter vistaDbParameter)
16+
{
17+
if (vistaDbParameter == null)
18+
throw new ArgumentNullException("vistaDbParameter");
19+
20+
this.VistaDbParameter = vistaDbParameter;
21+
22+
_backgroundValue = vistaDbParameter.Value;
23+
}
24+
25+
#region IDbDataParameter Members
26+
27+
public byte Precision
28+
{
29+
get { return this.VistaDbParameter.Precision; }
30+
set { this.VistaDbParameter.Precision = value; }
31+
}
32+
33+
public byte Scale
34+
{
35+
get { return this.VistaDbParameter.Scale; }
36+
set { this.VistaDbParameter.Scale = value; }
37+
}
38+
39+
public int Size
40+
{
41+
get { return this.VistaDbParameter.Size; }
42+
set { this.VistaDbParameter.Size = value; }
43+
}
44+
45+
#endregion
46+
47+
#region IDataParameter Members
48+
49+
public DbType DbType
50+
{
51+
get { return this.VistaDbParameter.DbType; }
52+
set { this.VistaDbParameter.DbType = value; }
53+
}
54+
55+
public ParameterDirection Direction
56+
{
57+
get { return this.VistaDbParameter.Direction; }
58+
set { this.VistaDbParameter.Direction = value; }
59+
}
60+
61+
public bool IsNullable { get { return this.VistaDbParameter.IsNullable; } }
62+
63+
public string ParameterName
64+
{
65+
get { return this.VistaDbParameter.ParameterName; }
66+
set { this.VistaDbParameter.ParameterName = value; }
67+
}
68+
69+
public string SourceColumn
70+
{
71+
get { return this.VistaDbParameter.SourceColumn; }
72+
set { this.VistaDbParameter.SourceColumn = value; }
73+
}
74+
75+
public DataRowVersion SourceVersion
76+
{
77+
get { return this.VistaDbParameter.SourceVersion; }
78+
set { this.VistaDbParameter.SourceVersion = value; }
79+
}
80+
81+
public object Value
82+
{
83+
get { return _backgroundValue; }
84+
set
85+
{
86+
_backgroundValue = value;
87+
88+
var vistaDbValue = value; ;
89+
if (vistaDbValue != null && vistaDbValue.GetType().IsEnum)
90+
vistaDbValue = vistaDbValue.ToString();
91+
92+
this.VistaDbParameter.Value = vistaDbValue;
93+
}
94+
}
95+
96+
#endregion
97+
}
98+
}

0 commit comments

Comments
 (0)