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

Commit dc3ed75

Browse files
committed
Add SQL Cast test with expression
1 parent 9780636 commit dc3ed75

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/ServiceStack.OrmLite.Tests/SqlDialectTests.cs

+20-1
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,31 @@ public void Does_concat_values_in_SqlExpression()
5151
x.Id,
5252
text = Sql.As(Sql.Cast(x.Id, Sql.VARCHAR) + " : " + Sql.Cast(x.Value, Sql.VARCHAR) + " : " + Sql.Cast(x.Bool, Sql.VARCHAR) + " string", "text")
5353
}));
54-
54+
5555
Assert.That(results[0]["text"], Is.EqualTo("1 : 123.456 : 1 string")
5656
.Or.EqualTo("1 : 123.456 : true string"));
5757
}
5858
}
5959

60+
[Test]
61+
public void Does_concat_values_in_SqlExpression_using_tuple()
62+
{
63+
using (var db = OpenDbConnection())
64+
{
65+
db.DropAndCreateTable<Sqltest>();
66+
67+
db.Insert(new Sqltest { Value = 123.456 });
68+
69+
var results = db.Select<(int id, string text)>(db.From<Sqltest>()
70+
.Select(x => new {
71+
x.Id,
72+
text = Sql.Cast(x.Id, Sql.VARCHAR) + " : " + Sql.Cast(x.Value, Sql.VARCHAR) + " : " + Sql.Cast("1 + 2", Sql.VARCHAR) + " string"
73+
}));
74+
75+
Assert.That(results[0].text, Is.EqualTo("1 : 123.456 : 3 string"));
76+
}
77+
}
78+
6079
[Test]
6180
public void Does_format_currency()
6281
{

0 commit comments

Comments
 (0)