Because there is no managed method to activate another application, you can either use this class within the current application or use native Windows methods, such as FindWindow and SetForegroundWindow, to force focus on other applications.
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();
static void Main(string[] args)
{
var start = "1abc3";
GetCascading(start, 6);
}
static string[] GetCascading(string val, int count)
{
var result = new List<string>();
var intVal = int.Parse(val, System.Globalization.NumberStyles.HexNumber);
for (var i = 1; i < count + 1; i++) result.Add((intVal - i).ToString("X"));
return result.ToArray();
}