using(var context = new SampleContext())
{
var commandText = "INSERT Categories (CategoryName) VALUES (@CategoryName)";
var name = new SqlParameter("@CategoryName", "Test");
context.Database.ExecuteSqlCommand(commandText, name);
}
public class SqlItem
{
public SqlItem() { }
public SqlItem(XmlItem item)
{
Name = item.Name;
}
public string Name { get; set; }
}
using var ctx = new ApplicationDbContext(new Microsoft.EntityFrameworkCore.DbContextOptions<ApplicationDbContext>());
var serializer =new XmlSerializer(typeof(XmlItem[]));
var filename = "test.xml";
var fs = new FileStream(filename, FileMode.OpenOrCreate);
var reader = new StreamReader(fs);
var xmls = (XmlItem[])serializer.Deserialize(reader);
foreach (var item in xmls)
ctx.Items.Add(new SqlItem(item));
ctx.SaveChanges();
public class EventCreateModel{
public string Name {get;set;}
// проверяем если пустое то это просто Event, если нет то это командное
public string Team {get;set;}
}
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options =>
options.AddDefaultPolicy(builder =>
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader())
);
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider, ILogger<Startup> logger)
{
if (env.IsDevelopment()) app.UseDeveloperExceptionPage();
app.UseCors(options => options.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
}