This repository has been archived by the owner on Dec 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Substring SQL Expression to SQL Server
- Loading branch information
Showing
5 changed files
with
93 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/ServiceStack.OrmLite.Tests/Expression/SelectFieldExpressionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Linq; | ||
using NUnit.Framework; | ||
using ServiceStack.OrmLite.Tests.Shared; | ||
using ServiceStack.Text; | ||
|
||
namespace ServiceStack.OrmLite.Tests.Expression | ||
{ | ||
public class SelectFieldExpressionTests | ||
: OrmLiteTestBase | ||
{ | ||
[Test] | ||
public void Can_Select_Substring() | ||
{ | ||
using (var db = OpenDbConnection()) | ||
{ | ||
db.DropAndCreateTable<Person>(); | ||
db.InsertAll(Person.Rockstars); | ||
|
||
var results = db.Select<Person>(x => x.FirstName.Substring(1, 2) == "im"); | ||
|
||
results.PrintDump(); | ||
|
||
var expected = Person.Rockstars.Where(x => x.FirstName.Substring(1, 2) == "im").ToList(); | ||
|
||
Assert.That(results.Count, Is.EqualTo(expected.Count)); | ||
Assert.That(results, Is.EquivalentTo(expected)); | ||
|
||
results = db.Select<Person>(x => x.FirstName.Substring(1) == "im"); | ||
results.PrintDump(); | ||
|
||
expected = Person.Rockstars.Where(x => x.FirstName.Substring(1) == "im").ToList(); | ||
Assert.That(results.Count, Is.EqualTo(expected.Count)); | ||
Assert.That(results, Is.EquivalentTo(expected)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters