Errors when Flushing the database instance having changed an index to Tuple<DateTime, int>

Jun 9, 2011 at 8:31 PM

Hi there, I have cleared out all of the data "AppData\Local\Sterling Database\Databases", changed an index on a table to use a Tuple like so

CreateTableDefinition<Event, int>(x=>x.Id)
                    .WithIndex<Event, Tuple<DateTime, int>, int>(INDEX_VENUE_AND_DATE, x=> Tuple.Create<DateTime, int>(x.Date, x.VenueId)),

 Now, when I try to Flush the database instance I get the following error...

Unhandled Exception: Wintellect.Sterling.Exceptions.SterlingSerializerException:
 Serialization/deserialization failed because the serializer Wintellect.Sterling
.Serialization.AggregateSerializer could not process the type System.Tuple`2[[Sy
stem.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c
561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKey
Token=b77a5c561934e089]] requested.
   at Wintellect.Sterling.Serialization.AggregateSerializer.Serialize(Object tar
get, BinaryWriter writer) in C:\src\Sterling\src\SterlingSln\Wintellect.Sterling
\Serialization\AggregateSerializer.cs:line 119
   at Wintellect.Sterling.Server.FileSystem.FileSystemDriver.SerializeIndex[TKey
,TIndex](Type type, String indexName, Dictionary`2 indexMap) in c:\src\Sterling\
src\SterlingSln\Wintellect.Sterling.Server.FileSystem\FileSystemDriver.cs:line 1
20
   at Wintellect.Sterling.Indexes.IndexCollection`3.SerializeIndexes() in C:\src
\Sterling\src\SterlingSln\Wintellect.Sterling\Indexes\IndexCollection.cs:line 87

   at Wintellect.Sterling.Indexes.IndexCollection`3.Flush() in C:\src\Sterling\s
rc\SterlingSln\Wintellect.Sterling\Indexes\IndexCollection.cs:line 99
   at Wintellect.Sterling.Database.BaseDatabaseInstance.Flush() in C:\src\Sterli
ng\src\SterlingSln\Wintellect.Sterling\Database\BaseDatabaseInstance.cs:line 687

 

When I indexed solely on DateTime, it was fine. 

Any ideas?

thanks

Kris

 

 

Coordinator
Jun 10, 2011 at 12:46 AM

I think what you want is:

.WithIndex<Event, DateTime, int, int> - the tuple is implied, and allows Sterling to handle the DateTime, int separately. That creates an index with two values and you access it with a tuple.

What you're doing is creating an index with one value, which happens to be a tuple. Because the tuple itself isn't serializeable, you'd have to write a custom serializer that knows how to breakdown the tuple and then rebuild it.

Jun 10, 2011 at 8:49 AM

ok, thanks - that did it.  much appreciated.