首页 > 解决方案 > LiteDB - case sensitivity when storing Dictionary()

问题描述

I am storing an object in LiteDB containing a Dictionary<> with a key of type string, i.e. Dictionary<string, ..> My problem is that on loading the object back from LiteDB, Dictionary<> objects with key values that differ only by case are lost and only one is read back into the Dictionary<>. This is despite trying everything I can see to enable Ordinal collation and case sensitivity. The code to open the DB uses a ConnectionString as follows.

static private readonly ConnectionString ConnectionString = new ConnectionString(PdbPath(true))
{
    Collation = new Collation(0x0409, System.Globalization.CompareOptions.Ordinal)       // "en-US" Ordinal
};
Database = new LiteDatabase(ConnectionString);
BsonMapper.Global.TrimWhitespace = false;       // don't trim whitespace from the front of strings
// serialisation overrides
BsonMapper.Global.RegisterType<...

Is there an option to have LiteDB store and load a Dictionary<string,...> object with all the original keys/values, even for keys that differ only by case?

Thanks.

标签: dictionarylitedb

解决方案


推荐阅读