コード例 #1
0
        private static string GetRevisionTableIdentifier(ISqlDialect sqlDialect)
        {
            var classDefinition = MappingConfiguration.Current.GetTypeDefinition(typeof(SecurableClassDefinition));
            var tableDefinition = (TableDefinition)classDefinition.StorageEntityDefinition;

            if (tableDefinition.TableName.SchemaName == null)
            {
                return(sqlDialect.DelimitIdentifier("Revision"));
            }
            else
            {
                return(sqlDialect.DelimitIdentifier(tableDefinition.TableName.SchemaName) + "." + sqlDialect.DelimitIdentifier("Revision"));
            }
        }
コード例 #2
0
        public void AppendOrderings(StringBuilder stringBuilder, ISqlDialect sqlDialect)
        {
            ArgumentUtility.CheckNotNull("stringBuilder", stringBuilder);
            ArgumentUtility.CheckNotNull("sqlDialect", sqlDialect);

            stringBuilder.Append(
                string.Join(", ", _columns.Select(orderedColumn =>
                                                  sqlDialect.DelimitIdentifier(orderedColumn.ColumnDefinition.Name) + (orderedColumn.SortOrder == SortOrder.Ascending ? " ASC" : " DESC"))));
        }
コード例 #3
0
        public void AppendColumnNames(StringBuilder statement, IDbCommand dbCommand, ISqlDialect sqlDialect)
        {
            ArgumentUtility.CheckNotNull("statement", statement);
            ArgumentUtility.CheckNotNull("dbCommand", dbCommand);
            ArgumentUtility.CheckNotNull("sqlDialect", sqlDialect);

            var columNames = string.Join(", ", _columnValues.Select(cv => sqlDialect.DelimitIdentifier(cv.Column.Name)));

            statement.Append(columNames);
        }
        public void AppendComparisons(
            StringBuilder statement, IDbCommand command, ISqlDialect sqlDialect)
        {
            ArgumentUtility.CheckNotNull("statement", statement);
            ArgumentUtility.CheckNotNull("command", command);
            ArgumentUtility.CheckNotNull("sqlDialect", sqlDialect);

            statement.Append(sqlDialect.DelimitIdentifier(_columnDefinition.Name));
            statement.Append(" IN (");
            statement.Append("SELECT T.c.value('.', '").Append(_columnDefinition.StorageTypeInfo.StorageTypeName).Append("')");
            statement.Append(" FROM ");
            statement.Append(GetParameterName(sqlDialect));
            statement.Append(".nodes('/L/I') T(c))");

            command.CommandText = statement.ToString();
        }
コード例 #5
0
        public void AppendComparisons(
            StringBuilder statement, IDbCommand command, ISqlDialect sqlDialect)
        {
            ArgumentUtility.CheckNotNull("statement", statement);
            ArgumentUtility.CheckNotNull("command", command);
            ArgumentUtility.CheckNotNull("sqlDialect", sqlDialect);

            bool first = true;

            foreach (var comparedColumnValue in _comparedColumnValues)
            {
                if (!first)
                {
                    statement.Append(" AND ");
                }

                statement.Append(sqlDialect.DelimitIdentifier(comparedColumnValue.Column.Name));
                statement.Append(" = ");

                statement.Append(GetParameterName(comparedColumnValue, sqlDialect));

                first = false;
            }
        }
コード例 #6
0
        public void AppendProjection(StringBuilder stringBuilder, ISqlDialect sqlDialect)
        {
            ArgumentUtility.CheckNotNull("stringBuilder", stringBuilder);
            ArgumentUtility.CheckNotNull("sqlDialect", sqlDialect);

            stringBuilder.Append(string.Join(", ", _selectedColumns.Select(c => c == null ? "NULL" : sqlDialect.DelimitIdentifier(c.Name))));
        }
コード例 #7
0
 private static string GetRevisionValueColumnIdentifier(ISqlDialect sqlDialect)
 {
     return(sqlDialect.DelimitIdentifier("Value"));
 }
コード例 #8
0
 private static string GetRevisionLocalKeyColumnIdentifier(ISqlDialect sqlDialect)
 {
     return(sqlDialect.DelimitIdentifier("LocalKey"));
 }
コード例 #9
0
        public void AppendColumnValueAssignments(StringBuilder statement, IDbCommand dbCommand, ISqlDialect sqlDialect)
        {
            ArgumentUtility.CheckNotNull("statement", statement);
            ArgumentUtility.CheckNotNull("dbCommand", dbCommand);
            ArgumentUtility.CheckNotNull("sqlDialect", sqlDialect);

            var columnsWithParameters = _columnValues.Select(
                cv =>
            {
                var parameter           = cv.Column.StorageTypeInfo.CreateDataParameter(dbCommand, cv.Value);
                parameter.ParameterName = sqlDialect.GetParameterName(cv.Column.Name);
                dbCommand.Parameters.Add(parameter);
                return(new { ColumnDefinition = cv.Column, Parameter = parameter });
            });

            var updateStatement = string.Join(", ", columnsWithParameters.Select(cp => string.Format("{0} = {1}", sqlDialect.DelimitIdentifier(cp.ColumnDefinition.Name), cp.Parameter.ParameterName)));

            statement.Append(updateStatement);
        }