コード例 #1
0
 public void GenerateUpdate_Test()
 {
     var types = new Cassandra.Mapping.Utils.LookupKeyedCollection<Type, ITypeDefinition>(td => td.PocoType);
     types.Add(new Map<ExplicitColumnsUser>().TableName("users").PartitionKey(u => u.UserId).Column(u => u.UserAge, cm => cm.WithName("AGE")));
     var pocoFactory = new PocoDataFactory(types);
     var cqlGenerator = new CqlGenerator(pocoFactory);
     var cql = cqlGenerator.GenerateUpdate<ExplicitColumnsUser>();
     Assert.AreEqual("UPDATE users SET Name = ?, AGE = ? WHERE UserId = ?", cql);
 }
コード例 #2
0
 public void AddSelect_Test()
 {
     var types = new Cassandra.Mapping.Utils.LookupKeyedCollection<Type, ITypeDefinition>(td => td.PocoType);
     types.Add(new Map<ExplicitColumnsUser>().TableName("users").PartitionKey(u => u.UserId).Column(u => u.UserAge, cm => cm.WithName("AGE")));
     var pocoFactory = new PocoDataFactory(types);
     var cqlGenerator = new CqlGenerator(pocoFactory);
     var cql = Cql.New("WHERE UserId = ?", Guid.Empty);
     cqlGenerator.AddSelect<ExplicitColumnsUser>(cql);
     Assert.AreEqual("SELECT UserId, Name, AGE FROM users WHERE UserId = ?", cql.Statement);
 }
コード例 #3
0
 public void PrependUpdate_Test()
 {
     var types = new Cassandra.Mapping.Utils.LookupKeyedCollection<Type, ITypeDefinition>(td => td.PocoType);
     types.Add(new Map<ExplicitColumnsUser>().TableName("users").PartitionKey(u => u.UserId));
     var pocoFactory = new PocoDataFactory(types);
     var cqlGenerator = new CqlGenerator(pocoFactory);
     var cql = Cql.New("SET Name = ? WHERE UserId = ?", "New name", Guid.Empty);
     cqlGenerator.PrependUpdate<ExplicitColumnsUser>(cql);
     Assert.AreEqual("UPDATE users SET Name = ? WHERE UserId = ?", cql.Statement);
 }
コード例 #4
0
        public void GenerateUpdate_Test()
        {
            var types = new Cassandra.Mapping.Utils.LookupKeyedCollection <Type, ITypeDefinition>(td => td.PocoType);

            types.Add(new Map <ExplicitColumnsUser>().TableName("users").PartitionKey(u => u.UserId).Column(u => u.UserAge, cm => cm.WithName("AGE")));
            var pocoFactory  = new PocoDataFactory(types);
            var cqlGenerator = new CqlGenerator(pocoFactory);
            var cql          = cqlGenerator.GenerateUpdate <ExplicitColumnsUser>();

            Assert.AreEqual("UPDATE users SET Name = ?, AGE = ? WHERE UserId = ?", cql);
        }
コード例 #5
0
        public void GenerateDelete_Test()
        {
            var types = new Cassandra.Mapping.Utils.LookupKeyedCollection <Type, ITypeDefinition>(td => td.PocoType);

            types.Add(new Map <ExplicitColumnsUser>().TableName("USERS").PartitionKey(u => u.UserId));
            var pocoFactory  = new PocoDataFactory(types);
            var cqlGenerator = new CqlGenerator(pocoFactory);
            var cql          = cqlGenerator.GenerateDelete <ExplicitColumnsUser>();

            Assert.AreEqual("DELETE FROM USERS WHERE UserId = ?", cql);
        }
コード例 #6
0
        public void AddSelect_Test()
        {
            var types = new Cassandra.Mapping.Utils.LookupKeyedCollection <Type, ITypeDefinition>(td => td.PocoType);

            types.Add(new Map <ExplicitColumnsUser>().TableName("users").PartitionKey(u => u.UserId).Column(u => u.UserAge, cm => cm.WithName("AGE")));
            var pocoFactory  = new PocoDataFactory(types);
            var cqlGenerator = new CqlGenerator(pocoFactory);
            var cql          = Cql.New("WHERE UserId = ?", Guid.Empty);

            cqlGenerator.AddSelect <ExplicitColumnsUser>(cql);
            Assert.AreEqual("SELECT UserId, Name, AGE FROM users WHERE UserId = ?", cql.Statement);
        }
コード例 #7
0
        public void PrependUpdate_Test()
        {
            var types = new Cassandra.Mapping.Utils.LookupKeyedCollection <Type, ITypeDefinition>(td => td.PocoType);

            types.Add(new Map <ExplicitColumnsUser>().TableName("users").PartitionKey(u => u.UserId));
            var pocoFactory  = new PocoDataFactory(types);
            var cqlGenerator = new CqlGenerator(pocoFactory);
            var cql          = Cql.New("SET Name = ? WHERE UserId = ?", "New name", Guid.Empty);

            cqlGenerator.PrependUpdate <ExplicitColumnsUser>(cql);
            Assert.AreEqual("UPDATE users SET Name = ? WHERE UserId = ?", cql.Statement);
        }
コード例 #8
0
        public void GenerateInsert_CaseSensitive_Test()
        {
            var types = new Cassandra.Mapping.Utils.LookupKeyedCollection <Type, ITypeDefinition>(td => td.PocoType);

            types.Add(new Map <ExplicitColumnsUser>()
                      .TableName("USERS")
                      .PartitionKey(u => u.UserId)
                      .CaseSensitive());
            var pocoFactory  = new PocoDataFactory(types);
            var cqlGenerator = new CqlGenerator(pocoFactory);
            var cql          = cqlGenerator.GenerateInsert <ExplicitColumnsUser>();

            Assert.AreEqual(@"INSERT INTO ""USERS"" (""UserId"", ""Name"", ""UserAge"") VALUES (?, ?, ?)", cql);
        }
コード例 #9
0
        public void GenerateInsert_Test()
        {
            var types = new Cassandra.Mapping.Utils.LookupKeyedCollection <Type, ITypeDefinition>(td => td.PocoType);

            types.Add(new Map <ExplicitColumnsUser>()
                      .TableName("USERS")
                      .PartitionKey("ID")
                      .Column(u => u.UserId, cm => cm.WithName("ID")));
            var pocoFactory  = new PocoDataFactory(types);
            var cqlGenerator = new CqlGenerator(pocoFactory);
            var cql          = cqlGenerator.GenerateInsert <ExplicitColumnsUser>();

            Assert.AreEqual(@"INSERT INTO USERS (ID, Name, UserAge) VALUES (?, ?, ?)", cql);
        }
コード例 #10
0
        public void GenerateDelete_CaseSensitive_Test()
        {
            var types = new Cassandra.Mapping.Utils.LookupKeyedCollection <Type, ITypeDefinition>(td => td.PocoType);

            types.Add(new Map <ExplicitColumnsUser>()
                      .TableName("USERS")
                      .PartitionKey("ID")
                      .Column(u => u.UserId, cm => cm.WithName("ID"))
                      .CaseSensitive());
            var pocoFactory  = new PocoDataFactory(types);
            var cqlGenerator = new CqlGenerator(pocoFactory);
            var cql          = cqlGenerator.GenerateDelete <ExplicitColumnsUser>();

            Assert.AreEqual(@"DELETE FROM ""USERS"" WHERE ""ID"" = ?", cql);
        }
コード例 #11
0
 public void GenerateDelete_Test()
 {
     var types = new Cassandra.Mapping.Utils.LookupKeyedCollection<Type, ITypeDefinition>(td => td.PocoType);
     types.Add(new Map<ExplicitColumnsUser>().TableName("USERS").PartitionKey(u => u.UserId));
     var pocoFactory = new PocoDataFactory(types);
     var cqlGenerator = new CqlGenerator(pocoFactory);
     var cql = cqlGenerator.GenerateDelete<ExplicitColumnsUser>();
     Assert.AreEqual("DELETE FROM USERS WHERE UserId = ?", cql);
 }
コード例 #12
0
 public void GenerateInsert_CaseSensitive_Test()
 {
     var types = new Cassandra.Mapping.Utils.LookupKeyedCollection<Type, ITypeDefinition>(td => td.PocoType);
     types.Add(new Map<ExplicitColumnsUser>()
         .TableName("USERS")
         .PartitionKey(u => u.UserId)
         .CaseSensitive());
     var pocoFactory = new PocoDataFactory(types);
     var cqlGenerator = new CqlGenerator(pocoFactory);
     var cql = cqlGenerator.GenerateInsert<ExplicitColumnsUser>();
     Assert.AreEqual(@"INSERT INTO ""USERS"" (""UserId"", ""Name"", ""UserAge"") VALUES (?, ?, ?)", cql);
 }
コード例 #13
0
 public void GenerateInsert_Test()
 {
     var types = new Cassandra.Mapping.Utils.LookupKeyedCollection<Type, ITypeDefinition>(td => td.PocoType);
     types.Add(new Map<ExplicitColumnsUser>()
         .TableName("USERS")
         .PartitionKey("ID")
         .Column(u => u.UserId, cm => cm.WithName("ID")));
     var pocoFactory = new PocoDataFactory(types);
     var cqlGenerator = new CqlGenerator(pocoFactory);
     var cql = cqlGenerator.GenerateInsert<ExplicitColumnsUser>();
     Assert.AreEqual(@"INSERT INTO USERS (ID, Name, UserAge) VALUES (?, ?, ?)", cql);
 }
コード例 #14
0
 public void GenerateDelete_CaseSensitive_Test()
 {
     var types = new Cassandra.Mapping.Utils.LookupKeyedCollection<Type, ITypeDefinition>(td => td.PocoType);
     types.Add(new Map<ExplicitColumnsUser>()
         .TableName("USERS")
         .PartitionKey("ID")
         .Column(u => u.UserId, cm => cm.WithName("ID"))
         .CaseSensitive());
     var pocoFactory = new PocoDataFactory(types);
     var cqlGenerator = new CqlGenerator(pocoFactory);
     var cql = cqlGenerator.GenerateDelete<ExplicitColumnsUser>();
     Assert.AreEqual(@"DELETE FROM ""USERS"" WHERE ""ID"" = ?", cql);
 }