Пример #1
0
        public Task DeleteAsync <T>(T poco, CqlQueryOptions queryOptions = null)
        {
            // Get the statement and bind values from POCO
            string             cql           = _cqlGenerator.GenerateDelete <T>();
            Func <T, object[]> getBindValues = _mapperFactory.GetValueCollector <T>(cql, primaryKeyValuesOnly: true);

            object[] values = getBindValues(poco);

            return(ExecuteAsync(Cql.New(cql, values, queryOptions ?? CqlQueryOptions.None)));
        }
        public void GenerateDelete_Test()
        {
            var types = new 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);
        }
        public void GenerateDelete_CaseSensitive_Test()
        {
            var types = new 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);
        }
Пример #4
0
        /// <inheritdoc />
        public Task DeleteAsync <T>(T poco, string executionProfile, CqlQueryOptions queryOptions = null)
        {
            if (executionProfile == null)
            {
                throw new ArgumentNullException(nameof(executionProfile));
            }

            // Get the statement and bind values from POCO
            string             cql           = _cqlGenerator.GenerateDelete <T>();
            Func <T, object[]> getBindValues = _mapperFactory.GetValueCollector <T>(cql, primaryKeyValuesOnly: true);

            object[] values      = getBindValues(poco);
            var      cqlInstance = Cql.New(cql, values, queryOptions ?? CqlQueryOptions.None).WithExecutionProfile(executionProfile);

            return(ExecuteAsync(cqlInstance));
        }
Пример #5
0
 public void GenerateDelete_Test()
 {
     var types = new 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 GenerateDelete_CaseSensitive_Test()
 {
     var types = new 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);
 }