datenbank referenzen geupdated

This commit is contained in:
2023-04-14 09:16:46 +02:00
parent 040b22f01e
commit e050983f7c
5 changed files with 25 additions and 26 deletions

View File

@@ -11,13 +11,13 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
{
public class SchachtDataService : PostgresqlDataService, ISchachtDataService
{
public SchachtDataService(string connectionstring) : base(connectionstring,"Schaechte")
public SchachtDataService(string connectionstring) : base(connectionstring,"schacht")
{
}
public async Task<Schacht> Create(Schacht entity)
{
string command = "INSERT INTO " + tableName + " (\"Objektbezeichnung\",\"RechtsWert\",\"HochWert\",\"SohlHoehe\",\"DeckelHoehe\",\"Entwaesserung\",\"ProjektId\") VALUES " +
string command = "INSERT INTO " + tableName + " (objektbezeichnung,rechtswert,hochwert,sohlhoehe,deckelhoehe,entwaesserung,ref_projekt_id) VALUES " +
"(@1,@2,@3,@4,@5,@6,@7) RETURNING \"Id\"";
using(var cmd = new NpgsqlCommand(command,conn))
{
@@ -63,7 +63,7 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
public async Task<IEnumerable<Schacht>> GetAllByProjekt(int projektID)
{
List<Schacht> result = new List<Schacht>();
string command = @"SELECT * FROM " + tableName + " WHERE \"ProjektId\" = @1";
string command = @"SELECT * FROM " + tableName + " WHERE ref_projekt_id = @1";
using (var cmd = new NpgsqlCommand(command, conn))
{
cmd.Parameters.AddWithValue("1", projektID);
@@ -86,9 +86,8 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
public async Task<Schacht> Update(Schacht entity)
{
string command = @"UPDATE " + tableName + "SET \"Objektbezeichnung\" =@1, \"RechtsWert\"=@2," +
" \"HochWert\"=@3, \"SohlHoehe\"=@4, \"DeckelHoehe\"=@5, \"Entwaesserung\"=@6," +
" \"ProjektId\"=@7 WHERE \"Id\"=@8";
string command = @"UPDATE " + tableName + "SET " +
"objektbezeichnung=@1, rechtswert=@2, hochwert=@3, sohlhoehe=@4, deckelhoehe=@5, entwaesserung=@6, ref_projekt_id=@7 WHERE schacht_id=@8";
using(var cmd = new NpgsqlCommand(command,conn))
{
cmd.Parameters.AddWithValue("1", entity.Objektbezeichnung);