0
|
1 using System;
|
|
2 using System.Linq;
|
|
3 using BLToolkit.Data.Linq;
|
|
4 using NUnit.Framework;
|
|
5
|
|
6 namespace Data.Linq.ProviderSpecific
|
|
7 {
|
|
8 [TestFixture]
|
|
9 public class MsSql2008 : TestBase
|
|
10 {
|
|
11 [Test]
|
|
12 public void SqlTest([IncludeDataContexts("Sql2008", "Sql2012")] string context)
|
|
13 {
|
|
14 using (var db = new TestDbManager(context))
|
|
15 using (var rd = db.SetCommand(@"
|
|
16 SELECT
|
|
17 DateAdd(Hour, 1, [t].[DateTimeValue]) - [t].[DateTimeValue]
|
|
18 FROM
|
|
19 [LinqDataTypes] [t]")
|
|
20 .ExecuteReader())
|
|
21 {
|
|
22 if (rd.Read())
|
|
23 {
|
|
24 var value = rd.GetValue(0);
|
|
25 }
|
|
26 }
|
|
27 }
|
|
28
|
|
29 [Test]
|
|
30 public void SqlTypeTest([IncludeDataContexts("Sql2008", "Sql2012")] string context)
|
|
31 {
|
|
32 using (var db = new TestDbManager(context))
|
|
33 {
|
|
34 var q =
|
|
35 from p in db.Parent
|
|
36 join c in db.Child on p.ParentID equals c.ParentID into g
|
|
37 from c in g.DefaultIfEmpty()
|
|
38 select new {p, b = Sql.AsSql((int?)c.ParentID) };
|
|
39
|
|
40 var list = q.ToList();
|
|
41
|
|
42
|
|
43 var value = db.SetCommand(@"SELECT SmallIntValue FROM LinqDataTypes WHERE ID = 1").ExecuteScalar<short>();
|
|
44
|
|
45 db.SetCommand(@"UPDATE LinqDataTypes SET SmallIntValue = @value WHERE ID = 1", db.Parameter("value", (ushort)value)).ExecuteNonQuery();
|
|
46 }
|
|
47 }
|
|
48 }
|
|
49 }
|