This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
tests/ServiceStack.OrmLite.Tests Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,9 @@ internal static ModelDefinition GetModelDefinition(this Type modelType)
9393 var i = 0 ;
9494 foreach ( var propertyInfo in objProperties )
9595 {
96+ if ( propertyInfo . GetIndexParameters ( ) . Length > 0 )
97+ continue ; //Is Indexer
98+
9699 var sequenceAttr = propertyInfo . FirstAttribute < SequenceAttribute > ( ) ;
97100 var computeAttr = propertyInfo . FirstAttribute < ComputeAttribute > ( ) ;
98101 var decimalAttribute = propertyInfo . FirstAttribute < DecimalLengthAttribute > ( ) ;
Original file line number Diff line number Diff line change 11using System ;
2+ using System . Collections . Generic ;
23using NUnit . Framework ;
34using ServiceStack . Common . Tests . Models ;
45using ServiceStack . OrmLite . Tests . Shared ;
@@ -263,5 +264,46 @@ public void Can_create_table_with_all_number_types()
263264 Assert . That ( ModelWithNumerics . ModelWithNumericsComparer . Equals ( fromDb , defaultValues ) ) ;
264265 }
265266 }
267+
268+ public class ModelWithIndexer
269+ {
270+ public int Id { get ; set ; }
271+ public string Name { get ; set ; }
272+
273+ public ModelWithIndexer ( )
274+ {
275+ Attributes = new Dictionary < string , object > ( ) ;
276+ }
277+
278+ public Object this [ string attributeName ]
279+ {
280+ get
281+ {
282+ return Attributes [ attributeName ] ;
283+ }
284+ set
285+ {
286+ Attributes [ attributeName ] = value ;
287+ }
288+ }
289+
290+ Dictionary < string , object > Attributes { get ; set ; }
291+ }
292+
293+ [ Test ]
294+ public void Can_create_table_ModelWithIndexer ( )
295+ {
296+ using ( var db = OpenDbConnection ( ) )
297+ {
298+ db . DropAndCreateTable < ModelWithIndexer > ( ) ;
299+
300+ db . Insert ( new ModelWithIndexer { Id = 1 , Name = "foo" } ) ;
301+
302+ var row = db . SingleById < ModelWithIndexer > ( 1 ) ;
303+
304+ Assert . That ( row . Name , Is . EqualTo ( "foo" ) ) ;
305+ }
306+ }
307+
266308 }
267309}
You can’t perform that action at this time.
0 commit comments