DB 접근 시스템 제작완료
This commit is contained in:
parent
2ead30c1ed
commit
f6c8bb6f91
|
|
@ -4,9 +4,9 @@ namespace Server.SQL
|
|||
{
|
||||
public class DynamicData
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string NickName { get; set; }
|
||||
public string count { get; set; }
|
||||
public int index { get; set; }
|
||||
public string name { get; set; }
|
||||
public string data { get; set; }
|
||||
}
|
||||
|
||||
public class DynamicDataSQL : SQL<DynamicData>
|
||||
|
|
@ -15,5 +15,15 @@ namespace Server.SQL
|
|||
|
||||
protected override string ConnectionString => "dynamic_data";
|
||||
}
|
||||
|
||||
public DynamicData GetDataByName(string name)
|
||||
{
|
||||
return Table.SingleOrDefault(data => data.name == name);
|
||||
}
|
||||
|
||||
// index를 기준으로 데이터 조회
|
||||
public DynamicData GetDataByIndex(int index)
|
||||
{
|
||||
return Table.SingleOrDefault(data => data.index == index);
|
||||
}
|
||||
}
|
||||
//쿼리 전송
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Server.System;
|
||||
|
||||
namespace Server.SQL
|
||||
{
|
||||
|
|
@ -7,13 +8,11 @@ namespace Server.SQL
|
|||
|
||||
public abstract DbSet<T> Table { get; set; }
|
||||
|
||||
protected abstract string ConnectionString { get; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
optionsBuilder.UseNpgsql(ConnectionString);
|
||||
optionsBuilder.UseNpgsql(STATICS.SQL_URL);
|
||||
// 다른 옵션들을 추가할 수 있습니다.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue