Skip to content

Commit b457655

Browse files
committed
Adding StoredProcedure stuff to Ado adapter
1 parent 9af7a59 commit b457655

32 files changed

+291
-76
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace Simple.Data.Ado
7+
{
8+
internal partial class AdoAdapter : IAdapterWithFunctions
9+
{
10+
public bool IsValidFunction(string functionName)
11+
{
12+
throw new NotImplementedException();
13+
}
14+
15+
public FunctionReturnType GetReturnType(string functionName)
16+
{
17+
throw new NotImplementedException();
18+
}
19+
20+
public object ExecuteScalar(string functionName, IEnumerable<KeyValuePair<string, object>> parameters)
21+
{
22+
throw new NotImplementedException();
23+
}
24+
25+
public IEnumerable<IEnumerable<KeyValuePair<string, object>>> ExecuteResultSet(string functionName, IEnumerable<KeyValuePair<string, object>> parameters)
26+
{
27+
throw new NotImplementedException();
28+
}
29+
30+
public IEnumerable<IEnumerable<IEnumerable<KeyValuePair<string, object>>>> ExecuteMultipleResultSets(string functionName, IEnumerable<KeyValuePair<string, object>> parameters)
31+
{
32+
throw new NotImplementedException();
33+
}
34+
}
35+
}

Simple.Data.Ado/AdoAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Simple.Data.Ado
1313
{
1414
[Export("Ado", typeof(Adapter))]
15-
internal class AdoAdapter : Adapter, IAdapterWithRelation, IAdapterWithTransactions
15+
internal partial class AdoAdapter : Adapter, IAdapterWithRelation, IAdapterWithTransactions
1616
{
1717
private IConnectionProvider _connectionProvider;
1818
private DatabaseSchema _schema;

Simple.Data.Ado/DataRecordExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static dynamic ToDynamicRecord(this IDataRecord dataRecord)
1313

1414
public static dynamic ToDynamicRecord(this IDataRecord dataRecord, string tableName, Database database)
1515
{
16-
return new DynamicRecord(dataRecord.ToDictionary(), tableName, database);
16+
return new SimpleRecord(dataRecord.ToDictionary(), tableName, database);
1717
}
1818

1919
public static Dictionary<string, object> ToDictionary(this IDataRecord dataRecord)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace Simple.Data.Ado.Schema
8+
{
9+
public class Parameter
10+
{
11+
private readonly string _name;
12+
private readonly Type _type;
13+
private readonly ParameterDirection _direction;
14+
15+
public Parameter(string name, Type type, ParameterDirection direction)
16+
{
17+
_name = name;
18+
_direction = direction;
19+
_type = type;
20+
}
21+
22+
public ParameterDirection Direction
23+
{
24+
get { return _direction; }
25+
}
26+
27+
public Type Type
28+
{
29+
get { return _type; }
30+
}
31+
32+
public string Name
33+
{
34+
get { return _name; }
35+
}
36+
}
37+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Simple.Data.Extensions;
6+
7+
namespace Simple.Data.Ado.Schema
8+
{
9+
public class StoredProcedure
10+
{
11+
private readonly string _name;
12+
private readonly string _schema;
13+
14+
public StoredProcedure(string name) : this(name, null)
15+
{
16+
}
17+
18+
public StoredProcedure(string name, string schema)
19+
{
20+
_name = name;
21+
_schema = schema.NullIfWhitespace();
22+
}
23+
24+
public string Schema
25+
{
26+
get { return _schema; }
27+
}
28+
29+
public string Name
30+
{
31+
get { return _name; }
32+
}
33+
}
34+
}

Simple.Data.Ado/Schema/Table.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ public class Table : IEquatable<Table>
1616
private readonly Lazy<Key> _lazyPrimaryKey;
1717
private readonly Lazy<ForeignKeyCollection> _lazyForeignKeys;
1818

19+
public Table(string name, TableType type) : this(name, null, type)
20+
{
21+
}
22+
1923
public Table(string name, string schema, TableType type)
2024
{
2125
_actualName = name;
22-
_schema = schema;
26+
_schema = string.IsNullOrWhiteSpace(schema) ? null : schema;
2327
_type = type;
2428
}
2529

Simple.Data.Ado/Simple.Data.Ado.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@
8787
<Compile Include="Schema\ForeignKeyCollection.cs" />
8888
<Compile Include="Schema\ISchemaProvider.cs" />
8989
<Compile Include="Schema\Key.cs" />
90+
<Compile Include="Schema\Parameter.cs" />
9091
<Compile Include="Schema\SchemaSpecificStringExtensions.cs" />
92+
<Compile Include="Schema\StoredProcedure.cs" />
9193
<Compile Include="Schema\Table.cs" />
9294
<Compile Include="Schema\TableCollection.cs" />
9395
<Compile Include="Schema\TableJoin.cs" />
@@ -104,6 +106,7 @@
104106
</ProjectReference>
105107
</ItemGroup>
106108
<ItemGroup>
109+
<Compile Include="AdoAdapter.IAdapterWithFunctions.cs" />
107110
<None Include="app.config" />
108111
<None Include="packages.config" />
109112
<None Include="Properties\Settings.settings">

Simple.Data.BehaviourTest/DatabaseTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public void TestUpdateWithDynamicObject()
146146
{
147147
var mockDatabase = new MockDatabase();
148148
dynamic database = CreateDatabase(mockDatabase);
149-
dynamic record = new DynamicRecord();
149+
dynamic record = new SimpleRecord();
150150
record.Id = 1;
151151
record.Name = "Steve";
152152
record.Age = 50;
@@ -162,7 +162,7 @@ public void TestUpdateByWithDynamicObject()
162162
{
163163
var mockDatabase = new MockDatabase();
164164
dynamic database = CreateDatabase(mockDatabase);
165-
dynamic record = new DynamicRecord();
165+
dynamic record = new SimpleRecord();
166166
record.Id = 1;
167167
record.Name = "Steve";
168168
record.Age = 50;

Simple.Data.BehaviourTest/SchemaQualifiedTableTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void TestUpdateWithDynamicObject()
145145
{
146146
var mockDatabase = new MockDatabase();
147147
dynamic database = CreateDatabase(mockDatabase);
148-
dynamic record = new DynamicRecord();
148+
dynamic record = new SimpleRecord();
149149
record.Id = 1;
150150
record.Name = "Steve";
151151
record.Age = 50;
@@ -161,7 +161,7 @@ public void TestUpdateByWithDynamicObject()
161161
{
162162
var mockDatabase = new MockDatabase();
163163
dynamic database = CreateDatabase(mockDatabase);
164-
dynamic record = new DynamicRecord();
164+
dynamic record = new SimpleRecord();
165165
record.Id = 1;
166166
record.Name = "Steve";
167167
record.Age = 50;

Simple.Data.BehaviourTest/TransactionTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void TestUpdateWithDynamicObject()
9090
{
9191
var mockDatabase = new MockDatabase();
9292
dynamic database = CreateDatabase(mockDatabase);
93-
dynamic record = new DynamicRecord();
93+
dynamic record = new SimpleRecord();
9494
record.Id = 1;
9595
record.Name = "Steve";
9696
record.Age = 50;
@@ -111,7 +111,7 @@ public void TestUpdateByWithDynamicObject()
111111
{
112112
var mockDatabase = new MockDatabase();
113113
dynamic database = CreateDatabase(mockDatabase);
114-
dynamic record = new DynamicRecord();
114+
dynamic record = new SimpleRecord();
115115
record.Id = 1;
116116
record.Name = "Steve";
117117
record.Age = 50;

0 commit comments

Comments
 (0)