Exemplo n.º 1
0
        public void Fetch_TimeUuid_Map_Key()
        {
            _session.Execute("CREATE TABLE tbl_timeuuid_map2 (id int primary key, my_map map<timeuuid, text>)");
            var map = new Map <PocoWithCollections <TimeUuid> >()
                      .Column(p => p.Id)
                      .Column(p => p.DictionaryTKeyString, c => c.WithName("my_map"))
                      .PartitionKey(p => p.Id)
                      .TableName("tbl_timeuuid_map2")
                      .ExplicitColumns();
            var mapper   = new Mapper(_session, new MappingConfiguration().Define(map));
            var inserted = new PocoWithCollections <TimeUuid>
            {
                Id = 1,
                DictionaryTKeyString = new Dictionary <TimeUuid, string> {
                    { TimeUuid.NewId(), "one" }
                }
            };

            mapper.Insert(inserted);
            var retrieved = mapper.Fetch <PocoWithCollections <TimeUuid> >("WHERE id = ?", inserted.Id).First();

            CollectionAssert.AreEqual(inserted.DictionaryTKeyString, retrieved.DictionaryTKeyString);
        }
Exemplo n.º 2
0
        public void Fetch_TimeUuid_Set()
        {
            _session.Execute("CREATE TABLE tbl_timeuuid_sortedset (id int primary key, my_set set<timeuuid>)");
            var map = new Map <PocoWithCollections <TimeUuid> >()
                      .Column(p => p.Id)
                      .Column(p => p.SortedSet, c => c.WithName("my_set"))
                      .PartitionKey(p => p.Id)
                      .TableName("tbl_timeuuid_sortedset")
                      .ExplicitColumns();
            var mapper   = new Mapper(_session, new MappingConfiguration().Define(map));
            var inserted = new PocoWithCollections <TimeUuid>
            {
                Id        = 1,
                SortedSet = new SortedSet <TimeUuid> {
                    TimeUuid.NewId(), TimeUuid.NewId()
                }
            };

            mapper.Insert(inserted);
            var retrieved = mapper.Fetch <PocoWithCollections <TimeUuid> >("WHERE id = ?", inserted.Id).First();

            CollectionAssert.AreEqual(inserted.SortedSet, retrieved.SortedSet);
        }