48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
namespace Server.SQL
|
|
{
|
|
#if DEBUG
|
|
[Table("dynamic_data", Schema = "qa")]
|
|
#elif LIVE
|
|
[Table("dynamic_data", Schema = "live")]
|
|
#endif
|
|
public class DynamicData
|
|
{
|
|
public int id { get; set; }
|
|
public string name { get; set; }
|
|
public string value { get; set; }
|
|
}
|
|
|
|
public class DynamicDataSQL : SQL<DynamicData>
|
|
{
|
|
public override DbSet<DynamicData> table { get; set; }
|
|
public override string tablename { get { return "dynamic_data"; } }
|
|
|
|
public DynamicData SelectName(string name)
|
|
{
|
|
return table.SingleOrDefault(data => data.name == name);
|
|
}
|
|
|
|
// index를 기준으로 데이터 조회
|
|
public DynamicData GetDataByIndex(int id)
|
|
{
|
|
return table.SingleOrDefault(data => data.id == id);
|
|
}
|
|
|
|
public void Update(int id, string value)
|
|
{
|
|
var existingData = table.FirstOrDefault(data => data.id == id);
|
|
|
|
if (existingData != null)
|
|
{
|
|
existingData.value = value;
|
|
SaveChanges();
|
|
}
|
|
}
|
|
}
|
|
}
|