2021-04-02 17:28:07 +05:00
|
|
|
|
using AsbCloudDb.Model;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace ConsoleApp1
|
|
|
|
|
{
|
2021-04-23 10:21:25 +05:00
|
|
|
|
public class A
|
|
|
|
|
{
|
2021-04-07 18:01:56 +05:00
|
|
|
|
public int P1 { get; set; }
|
|
|
|
|
public int P2 { get; set; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public class B
|
|
|
|
|
{
|
|
|
|
|
public int P1 { get; set; }
|
|
|
|
|
public int P3 { get; set; }
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-02 17:28:07 +05:00
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
2021-04-23 10:21:25 +05:00
|
|
|
|
var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
|
|
|
|
.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
|
|
|
|
|
.Options;
|
|
|
|
|
var context = new AsbCloudDbContext(options);
|
|
|
|
|
|
|
|
|
|
var e = new Event
|
|
|
|
|
{
|
|
|
|
|
IdEvent = 1,
|
|
|
|
|
IdTelemetry = 1,
|
|
|
|
|
IdCategory = 1,
|
|
|
|
|
MessageTemplate = "template",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
context.Events.Update(e).State = EntityState.Added;
|
|
|
|
|
context.SaveChanges();
|
|
|
|
|
|
2021-04-08 17:54:02 +05:00
|
|
|
|
|
|
|
|
|
//var table = new Table
|
|
|
|
|
//{
|
|
|
|
|
// Headers = new List<Header>
|
|
|
|
|
// {
|
|
|
|
|
// new Header {Name = "P1", PropertyType = typeof(int) },
|
|
|
|
|
// new Header {Name = "P2", PropertyType = typeof(int) },
|
|
|
|
|
// new Header {Name = "P3", PropertyType = typeof(int) },
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
// Rows = new List<object[]>
|
|
|
|
|
// {
|
|
|
|
|
// new object[] {1,2,3 },
|
|
|
|
|
// new object[] {4,5,6 },
|
|
|
|
|
// new object[] {7,8,9 },
|
|
|
|
|
// }
|
|
|
|
|
//};
|
|
|
|
|
//var mapper = new TableMapper<B>();
|
|
|
|
|
|
|
|
|
|
//var b = new B();
|
|
|
|
|
//mapper.UpdateObjectFromTable(ref b, table, 1);
|
2021-04-23 10:21:25 +05:00
|
|
|
|
|
2021-04-08 17:54:02 +05:00
|
|
|
|
|
|
|
|
|
Console.WriteLine("Done. Press any key to quit.");
|
|
|
|
|
Console.ReadKey();
|
2021-04-02 17:28:07 +05:00
|
|
|
|
}
|
2021-04-07 18:01:56 +05:00
|
|
|
|
|
2021-04-23 10:21:25 +05:00
|
|
|
|
|
2021-04-02 17:28:07 +05:00
|
|
|
|
}
|
|
|
|
|
}
|