Ejemplo n.º 1
0
        /// <summary>
        /// Adds "SELECT columnlist" and "FROM tablename" to a CQL statement if they don't already exist for a POCO of Type T.
        /// </summary>
        public void AddSelect <T>(Cql cql)
        {
            // If it's already got a SELECT clause, just bail
            if (SelectRegex.IsMatch(cql.Statement))
            {
                return;
            }

            // Get the PocoData so we can generate a list of columns
            var pocoData   = _pocoDataFactory.GetPocoData <T>();
            var allColumns = pocoData.Columns.Select(Escape(pocoData)).ToCommaDelimitedString();

            // If it's got the from clause, leave FROM intact, otherwise add it
            cql.SetStatement(FromRegex.IsMatch(cql.Statement)
                                 ? string.Format("SELECT {0} {1}", allColumns, cql.Statement)
                                 : string.Format("SELECT {0} FROM {1} {2}", allColumns, Escape(pocoData.TableName, pocoData), cql.Statement));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds "SELECT columnlist" and "FROM tablename" to a CQL statement if they don't already exist for a POCO of Type T.
        /// </summary>
        public void AddSelect <T>(Cql cql)
        {
            // If it's already got a SELECT clause, just bail
            if (CqlGenerator.SelectRegex.IsMatch(cql.Statement))
            {
                return;
            }

            // Get the PocoData so we can generate a list of columns
            var pocoData   = _pocoDataFactory.GetPocoData <T>();
            var allColumns = pocoData.Columns.Select(CqlGenerator.EscapeFunc(pocoData)).ToCommaDelimitedString();

            var suffix = cql.Statement == string.Empty ? string.Empty : " " + cql.Statement;

            // If it's got the from clause, leave FROM intact, otherwise add it
            cql.SetStatement(CqlGenerator.FromRegex.IsMatch(cql.Statement)
                                 ? $"SELECT {allColumns}{suffix}"
                                 : $"SELECT {allColumns} FROM " +
                             $"{CqlGenerator.CqlIdentifierHelper.EscapeTableNameIfNecessary(pocoData, pocoData.KeyspaceName, pocoData.TableName)}" +
                             $"{suffix}");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Prepends the CQL statement specified with "DELETE FROM tablename " for a POCO of Type T.
        /// </summary>
        public void PrependDelete <T>(Cql cql)
        {
            PocoData pocoData = _pocoDataFactory.GetPocoData <T>();

            cql.SetStatement(string.Format("DELETE FROM {0} {1}", GetEscapedTableName(pocoData), cql.Statement));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Prepends the CQL statement specified with "UPDATE tablename " for a POCO of Type T.
        /// </summary>
        public void PrependUpdate <T>(Cql cql)
        {
            var pocoData = _pocoDataFactory.GetPocoData <T>();

            cql.SetStatement(string.Format("UPDATE {0} {1}", GetEscapedTableName(pocoData), cql.Statement));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Prepends the CQL statement specified with "DELETE FROM tablename " for a POCO of Type T.
        /// </summary>
        public void PrependDelete <T>(Cql cql)
        {
            var pocoData = _pocoDataFactory.GetPocoData <T>();

            cql.SetStatement($"DELETE FROM {CqlGenerator.CqlIdentifierHelper.EscapeTableNameIfNecessary(pocoData, pocoData.KeyspaceName, pocoData.TableName)} {cql.Statement}");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Prepends the CQL statement specified with "UPDATE tablename " for a POCO of Type T.
        /// </summary>
        public void PrependUpdate <T>(Cql cql)
        {
            PocoData pocoData = _pocoDataFactory.GetPocoData <T>();

            cql.SetStatement(string.Format("UPDATE {0} {1}", pocoData.TableName, cql.Statement));
        }