public async Task usingの指定() { var engine = new SqlTemplateEngine(); var definition = await engine.ExecuteAsync(File.ReadAllText("TestFiles\\Simple-using.tmpl.sql"), new User() { Name = "Foo" }).ConfigureAwait(false); var text = definition.SqlText; }
public void パブリックでないパラメーターモデルは例外が発生する() { var engine = new SqlTemplateEngine(); Assert.ThrowsAsync <ArgumentException>(async() => { await engine.ExecuteAsync(File.ReadAllText("TestFiles\\Simple-using.tmpl.sql"), new InternalUser { Name = "Foo" }); }); }
public async Task <int> ExecuteCommandAsync(string template, object model = null) { var engine = new SqlTemplateEngine(); var definition = model == null ? await engine.ExecuteAsync(File.ReadAllText(template)): await engine.ExecuteAsync(File.ReadAllText(template), model); var tempCommand = this.DbContext.Database.Connection.CreateCommand(); var parameters = definition.Parameters.Select(p => MapDefinitionToDbParameter(p, tempCommand)).ToArray(); tempCommand.Parameters.Clear(); tempCommand.Connection = null; return(await this.DbContext.Database.ExecuteSqlCommandAsync(definition.SqlText, parameters)); }