/
AdoNetDataAccessTests.cs
58 lines (50 loc) · 1.73 KB
/
AdoNetDataAccessTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using NUnit.Framework;
using ServiceStack.Text;
namespace ServiceStack.OrmLite.Tests
{
[TestFixtureOrmLiteDialects(Dialect.AnySqlServer)]
[Ignore("Required DB with MigrateSqlServerTypes table")]
public class AdoNetDataAccessTests : OrmLiteProvidersTestBase
{
public AdoNetDataAccessTests(DialectContext context) : base(context) {}
/*
CREATE TABLE [dbo].[MigrateSqlServerTypes](
[Id] [int] IDENTITY(1,1) NOT NULL,
[SqlServerTime] [time](7) NULL,
[OrmLiteTimeSpan] [bigint] NULL,
)
*/
public class MigrateSqlServerTypes
{
public int Id { get; set; }
public TimeSpan OrmLiteTimeSpan { get; set; }
}
[Test]
[Ignore("Needs review - MONOREPO")]
public void Can_read_from_existing_database()
{
using var db = OpenDbConnection();
var map = new Dictionary<int, TimeSpan>();
using (var dbCmd = db.CreateCommand())
{
dbCmd.CommandText = "SELECT * FROM MigrateSqlServerTypes";
using (var reader = dbCmd.ExecuteReader())
{
while (reader.Read())
{
var id = reader.GetInt32(0);
var sqlTime = (TimeSpan)reader.GetValue(1);
map[id] = sqlTime;
}
}
}
foreach (var entry in map)
{
db.Update(new MigrateSqlServerTypes { Id = entry.Key, OrmLiteTimeSpan = entry.Value });
}
db.Select<MigrateSqlServerTypes>().PrintDump();
}
}
}