This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
src/ServiceStack.OrmLite/Expressions
tests/ServiceStack.OrmLite.Tests Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -615,6 +615,8 @@ protected SqlExpression<T> AppendToEnsure(Expression predicate)
615615 if ( predicate == null )
616616 return this ;
617617
618+ Reset ( ) ;
619+
618620 var newExpr = WhereExpressionToString ( Visit ( predicate ) ) ;
619621 return Ensure ( newExpr ) ;
620622 }
Original file line number Diff line number Diff line change @@ -196,5 +196,22 @@ void assertEnsure(SqlExpression<Rockstar> q)
196196
197197 assertEnsure ( q ) ;
198198 }
199+
200+ [ Test ]
201+ public void Ensure_does_use_aliases ( )
202+ {
203+ using var db = OpenDbConnection ( ) ;
204+ db . DropAndCreateTable < ModelWithAlias > ( ) ;
205+
206+ db . Insert ( new ModelWithAlias {
207+ IntField = 1 ,
208+ } ) ;
209+
210+ var q = db . From < ModelWithAlias > ( )
211+ . Ensure ( x => x . IntField > 0 ) ;
212+
213+ var results = db . Select ( q ) ;
214+ Assert . That ( results . Count , Is . EqualTo ( 1 ) ) ;
215+ }
199216 }
200217}
Original file line number Diff line number Diff line change @@ -50,6 +50,17 @@ public class ModelWithAliasedRowVersion
5050 public long Version { get ; set ; }
5151 }
5252
53+ [ Alias ( "ModelAlias" ) ]
54+ public class ModelWithAlias
55+ {
56+ [ Alias ( "ModelId" ) ]
57+ [ AutoIncrement ]
58+ public int Id { get ; set ; }
59+
60+ [ Alias ( "IntAlias" ) ]
61+ public int IntField { get ; set ; }
62+ }
63+
5364 [ Schema ( "Schema" ) ]
5465 public class ModelWithSchemaAndRowVersionForInnerJoin
5566 {
You can’t perform that action at this time.
0 commit comments