public void TestGenericCacheTypes() { var cfg = new CacheConfiguration(TestUtils.TestName) { QueryEntities = new[] { new QueryEntity(typeof(GenericTest <int>), typeof(GenericTest2 <string>)) } }; var cache = Ignition.GetIgnite().GetOrCreateCache <GenericTest <int>, GenericTest2 <string> >(cfg); var key = new GenericTest <int>(1); var value = new GenericTest2 <string>("foo"); cache[key] = value; var query = cache.AsCacheQueryable() .Where(x => x.Key.Foo == key.Foo && x.Value.Bar == value.Bar) .Select(x => x.Value.Bar); var sql = query.ToCacheQueryable().GetFieldsQuery().Sql; var res = query.ToList(); Assert.AreEqual(1, res.Count); Assert.AreEqual(value.Bar, res[0]); var expectedSql = string.Format("select _T0.BAR from \"{0}\".GENERICTEST2 as", cache.Name); StringAssert.StartsWith(expectedSql, sql); }
public void TestGenericQueryTypes() { var ignite = Ignition.Start(TestUtils.GetTestConfiguration()); var cfg = new CacheConfiguration(TestUtils.TestName) { QueryEntities = new[] { new QueryEntity(typeof(GenericTest <int>), typeof(GenericTest2 <string>)) } }; var cache = ignite.GetOrCreateCache <GenericTest <int>, GenericTest2 <string> >(cfg); var key = new GenericTest <int>(1); var value = new GenericTest2 <string>("foo"); cache[key] = value; var binType = ignite.GetBinary().GetBinaryType(value.GetType()); var expectedTypeName = BinaryBasicNameMapper.FullNameInstance.GetTypeName(value.GetType().FullName); var expectedTypeId = BinaryUtils.GetStringHashCodeLowerCase(expectedTypeName); Assert.AreEqual(expectedTypeName, binType.TypeName); Assert.AreEqual(expectedTypeId, binType.TypeId); var queryEntity = cache.GetConfiguration().QueryEntities.Single(); Assert.AreEqual(expectedTypeName, queryEntity.ValueTypeName); var sqlRes = cache.Query(new SqlFieldsQuery("SELECT Foo, Bar from GENERICTEST2")).Single(); Assert.AreEqual(key.Foo, sqlRes[0]); Assert.AreEqual(value.Bar, sqlRes[1]); }
public void TestGenericQueryTypes() { var ignite = Ignition.Start(TestUtils.GetTestConfiguration()); var cfg = new CacheConfiguration(TestUtils.TestName) { QueryEntities = new[] { new QueryEntity(typeof(GenericTest <int>), typeof(GenericTest2 <string>)) } }; var cache = ignite.GetOrCreateCache <GenericTest <int>, GenericTest2 <string> >(cfg); var key = new GenericTest <int>(1); var value = new GenericTest2 <string>("foo"); cache[key] = value; var binType = ignite.GetBinary().GetBinaryType(value.GetType()); var expectedTypeName = BinaryBasicNameMapper.FullNameInstance.GetTypeName(value.GetType().FullName); var expectedTypeId = BinaryUtils.GetStringHashCodeLowerCase(expectedTypeName); Assert.AreEqual(expectedTypeName, binType.TypeName); Assert.AreEqual(expectedTypeId, binType.TypeId); var queryEntity = cache.GetConfiguration().QueryEntities.Single(); Assert.AreEqual(expectedTypeName, queryEntity.ValueTypeName); var tableName = cache.Query(new SqlFieldsQuery( "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?", cache.Name)) .Single().Single(); // The table name is weird, see IGNITE-14064. var sqlRes = cache.Query(new SqlFieldsQuery(string.Format("SELECT Foo, Bar from \"{0}\"", tableName))) .Single(); Assert.AreEqual(key.Foo, sqlRes[0]); Assert.AreEqual(value.Bar, sqlRes[1]); }