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)
93
93
var i = 0 ;
94
94
foreach ( var propertyInfo in objProperties )
95
95
{
96
+ if ( propertyInfo . GetIndexParameters ( ) . Length > 0 )
97
+ continue ; //Is Indexer
98
+
96
99
var sequenceAttr = propertyInfo . FirstAttribute < SequenceAttribute > ( ) ;
97
100
var computeAttr = propertyInfo . FirstAttribute < ComputeAttribute > ( ) ;
98
101
var decimalAttribute = propertyInfo . FirstAttribute < DecimalLengthAttribute > ( ) ;
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using NUnit . Framework ;
3
4
using ServiceStack . Common . Tests . Models ;
4
5
using ServiceStack . OrmLite . Tests . Shared ;
@@ -263,5 +264,46 @@ public void Can_create_table_with_all_number_types()
263
264
Assert . That ( ModelWithNumerics . ModelWithNumericsComparer . Equals ( fromDb , defaultValues ) ) ;
264
265
}
265
266
}
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
+
266
308
}
267
309
}
You can’t perform that action at this time.
0 commit comments