src/Cassandra/Mapping/Statements/CqlGenerator.cs
/// <summary>
/// Generates an "UPDATE tablename SET columns = ? WHERE pkColumns = ?" statement for a POCO of Type T.
/// </summary>
Generates an "UPDATE tablename SET columns = . WHERE pkColumns = ?" statement for a POCO of Type T.
Generates an " UPDATE tablename SET columns = . WHERE pkColumns = ? " statement for a POCO of Type T .
public string GenerateUpdate<T>()
        {
            var pocoData = _pocoDataFactory.GetPocoData<T>();
            if (pocoData.Columns.Count == 0)
                throw new InvalidOperationException(string.Format(NoColumns, "UPDATE", typeof(T).Name));
            if (pocoData.MissingPrimaryKeyColumns.Count > 0)
            {
                throw new InvalidOperationException(string.Format(MissingPkColumns, "UPDATE", typeof(T).Name,
                                                                  pocoData.MissingPrimaryKeyColumns.ToCommaDelimitedString()));
            }
            var nonPkColumns = pocoData.GetNonPrimaryKeyColumns().Select(Escape(pocoData, "{0} = ?")).ToCommaDelimitedString();
            var pkColumns = string.Join(" AND ", pocoData.GetPrimaryKeyColumns().Select(Escape(pocoData, "{0} = ?")));
            return string.Format("UPDATE {0} SET {1} WHERE {2}", GetEscapedTableName(pocoData), nonPkColumns, pkColumns);
        }
public string GenerateUpdate < T > ( ) { var pocoData = _pocoDataFactory . GetPocoData < T > ( ) ; if ( pocoData . Columns . Count == 0 ) throw new InvalidOperationException ( string . Format ( NoColumns , " " , typeof ( T ) . Name ) ) ; if ( pocoData . MissingPrimaryKeyColumns . Count > 0 ) { throw new InvalidOperationException ( string . Format ( MissingPkColumns , " " , typeof ( T ) . Name , pocoData . MissingPrimaryKeyColumns . ToCommaDelimitedString ( ) ) ) ; } var nonPkColumns = pocoData . GetNonPrimaryKeyColumns ( ) . Select ( Escape ( pocoData , " " ) ) . ToCommaDelimitedString ( ) ; var pkColumns = string . Join ( " " , pocoData . GetPrimaryKeyColumns ( ) . Select ( Escape ( pocoData , " " ) ) ) ; return string . Format ( " " , GetEscapedTableName ( pocoData ) , nonPkColumns , pkColumns ) ; }
Generates an "UPDATE tablename SET columns = ?
Generates an " UPDATE tablename SET columns = ?