private string ToGerman(FormattableString src) { return string.Format( CultureInfo.CreateSpecificCulture("de-de"), src.Format, src.GetArguments()); }
protected override string ConstructFullSelectStatementInternal( string selectClause, string fromClause, FormattableString whereClause = null, FormattableString orderClause = null, long? skipRowsCount = null, long? limitRowsCount = null, bool forceTableColumnResolution = false) { var sql = this.ResolveWithCultureInvariantFormatter($"SELECT {selectClause} FROM {fromClause}"); if (whereClause != null) { sql += " WHERE " + this.ResolveWithSqlFormatter(whereClause, forceTableColumnResolution); } if (orderClause != null) { sql += " ORDER BY " + this.ResolveWithSqlFormatter(orderClause, forceTableColumnResolution); } if (limitRowsCount.HasValue || skipRowsCount.HasValue) { sql += this.ResolveWithCultureInvariantFormatter($" LIMIT {limitRowsCount ?? -1}"); } if (skipRowsCount.HasValue) { sql += this.ResolveWithCultureInvariantFormatter($" OFFSET {skipRowsCount}"); } return sql; }
public async Task <IActionResult> OnPostVerifyAsync() { System.FormattableString query = $"EXECUTE [dbo].[VerifyLedger]"; await _context.Database.ExecuteSqlInterpolatedAsync(query); return(RedirectToPage("/LedgerVerifications/Index")); }
/// <summary> /// Constructs a full batch select statement /// </summary> protected override string ConstructFullBatchSelectStatementInternal( FormattableString whereClause = null, FormattableString orderClause = null, long? skipRowsCount = null, long? limitRowsCount = null, object queryParameters = null) { var sql = this.ResolveWithCultureInvariantFormatter($"SELECT {this.ConstructColumnEnumerationForSelect()} FROM {this.GetTableName()}"); if (whereClause != null) { sql += string.Format(this.StatementFormatter, " WHERE {0}", whereClause); } if (orderClause != null) { sql += string.Format(this.StatementFormatter, " ORDER BY {0}", orderClause); } if (limitRowsCount.HasValue) { sql += string.Format(CultureInfo.InvariantCulture, " LIMIT {0}", limitRowsCount); } if (skipRowsCount.HasValue) { sql += string.Format(CultureInfo.InvariantCulture, " OFFSET {0}", skipRowsCount); } return sql; }
public override string ConstructFullBatchSelectStatement( FormattableString whereClause = null, FormattableString orderClause = null, int? skipRowsCount = null, int? limitRowsCount = null, object queryParameters = null) { var sql = $"SELECT {this.ConstructColumnEnumerationForSelect()} FROM {this.GetTableName()}"; if (whereClause != null) { sql += string.Format(CultureInfo.InvariantCulture, " WHERE {0}", whereClause); } if (orderClause != null) { sql += string.Format(CultureInfo.InvariantCulture, " ORDER BY {0}", orderClause); } if (skipRowsCount.HasValue) { sql += string.Format(CultureInfo.InvariantCulture, " OFFSET {0} ROWS", skipRowsCount); } if (limitRowsCount.HasValue) { sql += string.Format(CultureInfo.InvariantCulture, " FETCH NEXT {0} ROWS ONLY", limitRowsCount); } return sql; }
public void Log(LogSeverity severity, string source, FormattableString message, Exception exception = null) { if (severity <= Level) { try { Message(this, new LogMessageEventArgs(severity, source, message.ToString(), exception)); } catch { } //We dont want to log on log errors } }
private static Exception ProtocolError(FormattableString fs, object message = null) { var s = Invariant(fs); if (message != null) { s += "\n\n" + message; } Trace.Fail(s); return new InvalidDataException(s); }
public static string Invariant(FormattableString formattable) { if (formattable == null) { throw new ArgumentNullException(nameof(formattable)); } return formattable.ToString(CultureInfo.InvariantCulture); }
//public static string Invariant(FormattableString s) => // s.ToString(CultureInfo.InvariantCulture); public static void ShowDetails(FormattableString s) { WriteLine($"argument count: {s.ArgumentCount}"); WriteLine($"format: {s.Format}"); for (int i = 0; i < s.ArgumentCount; i++) { WriteLine($"Argument {i}: {s.GetArgument(i)}"); } }
/// <summary> /// Default constructor. /// </summary> public StatementSqlBuilderJoinInstruction( GenericStatementSqlBuilder sqlBuilder, SqlJoinType joinType, FormattableString whereClause, FormattableString orderClause) { this.SqlBuilder = sqlBuilder; this.JoinType = joinType; this.WhereClause = whereClause; this.OrderClause = orderClause; }
internal static SqlCommand ToSqlCommand(SqlConnection conn, FormattableString formattableString) { object[] args = formattableString.GetArguments(); var parameters = args.Select((value, position) => new InterpolatedSqlParameter(value, position)).ToArray(); string sql = string.Format(formattableString.Format, parameters); var command = new SqlCommand(sql, conn); foreach (var p in parameters) { command.Parameters.Add(p.ToSqlParameter()); } return command; }
public static SqlCommand NewSqlCommand( this SqlConnection conn, FormattableString formattableString) { SqlParameter[] sqlParameters = formattableString.GetArguments() .Select((value, position) => new SqlParameter(Invariant($"@p{position}"), value)) .ToArray(); object[] formatArguments = sqlParameters .Select(p => new FormatCapturingParameter(p)) .ToArray(); string sql = string.Format(formattableString.Format, formatArguments); var command = new SqlCommand(sql, conn); command.Parameters.AddRange(sqlParameters); return command; }
// To protect from overposting attacks, enable the specific properties you want to bind to. // For more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Employee).State = EntityState.Modified; try { string userName = HttpContext.User.Identity.Name; var ssn = new SqlParameter(); ssn.ParameterName = @"@SSN"; ssn.DbType = DbType.AnsiStringFixedLength; ssn.Direction = ParameterDirection.Input; ssn.Value = Employee.Ssn; ssn.Size = ssn.Value.ToString().Length; var salary = new SqlParameter(); salary.ParameterName = @"@Salary"; salary.DbType = DbType.Currency; salary.Direction = ParameterDirection.Input; salary.Value = Employee.Salary; System.FormattableString query = $"UPDATE [dbo].[Employees] SET [SSN] = {ssn}, [FirstName] = {Employee.FirstName}, [LastName] = {Employee.LastName}, [Salary] = {salary} WHERE [EmployeeID] = {Employee.EmployeeId}"; string queryString = $"UPDATE [dbo].[Employees] SET [SSN] = '{Employee.Ssn}', [FirstName] = '{Employee.FirstName}', [LastName] = '{Employee.LastName}', [Salary] = '{Employee.Salary}' WHERE [EmployeeID] = '{Employee.EmployeeId}'"; await _context.Database.ExecuteSqlInterpolatedAsync(query); await _context.Database.ExecuteSqlInterpolatedAsync($"INSERT INTO [dbo].[AuditEvents] ([UserName], [Query]) VALUES ({userName}, {queryString})"); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(Employee.EmployeeId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public void Verbose(string source, FormattableString message, Exception ex = null) => Log(LogSeverity.Verbose, source, message, ex);
private static Task<REvaluationResult> EvaluateNonReentrantAsync(this IRSessionEvaluation evaluation, FormattableString commandText) { return evaluation.EvaluateAsync(FormattableString.Invariant(commandText)); }
/// <summary> /// Format the given object in the current culture. This static method may be /// imported in C# by /// <code> /// using static System.FormattableString; /// </code>. /// Within the scope /// of that import directive an interpolated string may be formatted in the /// current culture by writing, for example, /// <code> /// CurrentCulture($"{{ lat = {latitude}; lon = {longitude} }}") /// </code> /// </summary> public static string CurrentCulture(FormattableString formattable) { ArgumentNullException.ThrowIfNull(formattable); return(formattable.ToString(Globalization.CultureInfo.CurrentCulture)); }
private string PointsInGerman(FormattableString invariantString) => Format( System.Globalization.CultureInfo.GetCultureInfo("de-de"), invariantString.Format, invariantString.GetArguments());
public static void LogVerboseF(this ILogger logger, FormattableString message) { logger.LogVerbose(message.Format, message.GetArguments()); }
public static string Invariant(FormattableString messageFormat) { return(messageFormat.ToString(CultureInfo.InvariantCulture)); }
public static string CurrentCulture(FormattableString formattable) => formattable?.ToString(CultureInfo.CurrentCulture);
/* * BASE METHODS */ private static void send_pm(string text, Player player, ChatCategory Category, DefaultChatTags Tags) { System.FormattableString s = $"{text}"; ChatManager.ServerMessageToPlayer(s, player.User, false, Tags, Category); }
static string Url(FormattableString str) { return str.ToString(UrlFormatProvider.Instance); }
public void Error(string source, FormattableString message, Exception ex = null) => Log(LogSeverity.Error, source, message, ex);
public static string Invariant(FormattableString formattable) { return(formattable.ToString(CultureInfo.InvariantCulture)); }
public static string Invariant([NotNull] FormattableString formattable) => formattable.ToString(CultureInfo.InvariantCulture);
public static string Invariant(FormattableString formattableString) { string str = formattableString.ToString(CultureInfo.InvariantCulture); return(str); }
FormattableString Interpolation(FormattableString str) => str;
public static string Invariant(FormattableString formattable) { return String.Format(CultureInfo.InvariantCulture, formattable.Format, formattable.GetArguments()); }
public static string Invariant (FormattableString formattable) => formattable.ToString(CultureInfo.InvariantCulture);
private static void send_msg(string text, ChatCategory Category, DefaultChatTags Tags) { System.FormattableString s = $"{text}"; ChatManager.ServerMessageToAll(s, false, Tags, Category); }
public void Info(string source, FormattableString message, Exception ex = null) => Log(LogSeverity.Info, source, message, ex);
/// <summary> /// 执行指定的命令。 /// </summary> /// <param name="fs">一个复合格式字符串</param> /// <returns>数据源查询与交互的执行器。</returns> public IDbExecutor Execute(FormattableString fs) { this.ThrowIfDisposed(); return this.Execute(this.Owner.Parse(fs)); }
public void Debug(string source, FormattableString message, Exception ex = null) => Log(LogSeverity.Debug, source, message, ex);
/// <summary> /// 执行指定的命令。 /// </summary> /// <param name="fs">一个复合格式字符串</param> /// <returns>数据源查询与交互的执行器。</returns> public IDbExecutor Execute(FormattableString fs) => this.Execute(this.Parse(fs));
/// <summary> /// Format the given object in the invariant culture. This static method may be /// imported in C# by /// <code> /// using static System.FormattableString; /// </code>. /// Within the scope /// of that import directive an interpolated string may be formatted in the /// invariant culture by writing, for example, /// <code> /// Invariant($""{{ lat = {latitude}; lon = {longitude} }}"") /// </code> /// </summary> public static string Invariant(FormattableString formattable) { if (formattable == null) { throw new ArgumentNullException("formattable"); } return formattable.ToString(Globalization.CultureInfo.InvariantCulture); }
/// <summary> /// 将一个复合格式字符串转换为 <see cref="ExecuteCommand"/> 的对象实例。 /// </summary> /// <param name="fs">一个复合格式字符串</param> /// <returns><see cref="ExecuteCommand"/> 的对象实例。</returns> public ExecuteCommand Parse(FormattableString fs) { if(fs == null) throw new ArgumentNullException(nameof(fs)); var parameters = new ExecuteParameterCollection(); var sfp = new SqlFormatProvider(parameters, this.Provider); var text = fs.ToString(sfp); return new ExecuteCommand(text, parameters); }
static void FormatPrint (FormattableString message) { Console.WriteLine(message); ++counter; }
public static void LogErrorF(this ILogger logger, Exception error, FormattableString message) { logger.LogError(new FormattedLogValues(message.Format, message.GetArguments()), error); }
public static void LogInformationF(this ILogger logger, FormattableString message) { logger.LogInformation(message.Format, message.GetArguments()); }
public static string Invariant(FormattableString formattable) => formattable?.ToString(Globalization.CultureInfo.InvariantCulture);