datenbank referenzen geupdated
This commit is contained in:
@@ -11,12 +11,12 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
{
|
||||
public class AuftraggeberDataService : PostgresqlDataService, IAuftraggeberDataService
|
||||
{
|
||||
public AuftraggeberDataService(string connectionstring) : base(connectionstring,"Auftraggebers") { }
|
||||
public AuftraggeberDataService(string connectionstring) : base(connectionstring,"auftraggeber") { }
|
||||
|
||||
public async Task<Auftraggeber> Create(Auftraggeber entity)
|
||||
{
|
||||
string command = "INSERT INTO "+tableName+" (\"Name\", \"Strasse\", \"Ort\", \"Postleitzahl\", \"Ansprechpartner\", \"Telefonnummer\") " +
|
||||
"VALUES(@1,@2,@3,@4,@5,@6) RETURNING \"Id\"";
|
||||
string command = "INSERT INTO "+tableName+" (name, strasse, ort, postleitzahl, ansprechpartner, telefonnummer) " +
|
||||
"VALUES(@1,@2,@3,@4,@5,@6) RETURNING auftraggeber_id";
|
||||
|
||||
await using (var cmd = new NpgsqlCommand(command, conn))
|
||||
{
|
||||
@@ -37,7 +37,7 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
public async Task<Auftraggeber> Get(int id)
|
||||
{
|
||||
Auftraggeber result = new Auftraggeber();
|
||||
using (var cmd = new NpgsqlCommand($"SELECT * FROM "+tableName+" WHERE \"Id\" = @1", conn))
|
||||
using (var cmd = new NpgsqlCommand($"SELECT * FROM "+tableName+" WHERE auftraggeber_id = @1", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", id);
|
||||
using var reader = await cmd.ExecuteReaderAsync();
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
{
|
||||
public class HaltungDataService : PostgresqlDataService, IHaltungDataService
|
||||
{
|
||||
public HaltungDataService(string connectionstring) : base(connectionstring, "Kanaele")
|
||||
public HaltungDataService(string connectionstring) : base(connectionstring, "haltung")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
ISchachtDataService schachtDataService = new SchachtDataService(connString);
|
||||
IEnumerable<Schacht> schaechte = await schachtDataService.GetAllByProjekt(projektID);
|
||||
|
||||
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);
|
||||
@@ -82,14 +82,14 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
{
|
||||
|
||||
string command = "UPDATE " + tableName + " SET " +
|
||||
" \"Objektbezeichnung\"=@1, " +
|
||||
" \"StartSchachtId\"=@2, " +
|
||||
" \"EndSchachtId\"=@3, " +
|
||||
" \"DN\"=@4, " +
|
||||
" \"Material\"=@5, " +
|
||||
" \"Haltungslaenge\"=@6, " +
|
||||
" \"Entwaesserung\"=@7 " +
|
||||
" WHERE \"Id\" = @8";
|
||||
" objektbezeichnung=@1, " +
|
||||
" ref_startschacht_id=@2, " +
|
||||
" ref_endschacht_id=@3, " +
|
||||
" dn=@4, " +
|
||||
" material=@5, " +
|
||||
" haltungslaenge=@6, " +
|
||||
" entwaesserung=@7 " +
|
||||
" WHERE haltung_id = @8";
|
||||
using(var cmd = new NpgsqlCommand(command,conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", entity.Objektbezeichnung);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
dataSource = dataSourceBuilder.Build();
|
||||
|
||||
conn = dataSource.OpenConnection();
|
||||
this.tableName = string.Format("public.\"{0}\"", tableName);
|
||||
this.tableName = string.Format("public.{0}", tableName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -14,15 +14,15 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
{
|
||||
public class ProjektDataService : PostgresqlDataService, IProjektDataService
|
||||
{
|
||||
public ProjektDataService(string connectionstring) : base(connectionstring,"Projekte")
|
||||
public ProjektDataService(string connectionstring) : base(connectionstring,"projekt")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public async Task<Projekt> Create(Projekt entity)
|
||||
{
|
||||
string command = "INSERT INTO "+tableName+" (\"Projektname\", \"Erstelldatum\", \"Strasse\", \"Ort\", \"ExportType\", \"Kodierungssystem\",\"AuftraggeberId\") " +
|
||||
"VALUES(@1,@2,@3,@4,@5,@6,@7) RETURNING \"Id\"";
|
||||
string command = "INSERT INTO "+tableName+" (projektname, erstelldatum, strasse, ort, exporttype, kodierungssystem,ref_auftraggeber_id) " +
|
||||
"VALUES(@1,@2,@3,@4,@5,@6,@7) RETURNING projekt_id";
|
||||
|
||||
if (entity.Auftraggeber.Id == 0)
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
{
|
||||
Projekt result = new Projekt();
|
||||
IAuftraggeberDataService auftraggeberDataService = new AuftraggeberDataService(connString);
|
||||
using (var cmd = new NpgsqlCommand($"SELECT * FROM "+tableName+" WHERE \"Id\" = @1", conn))
|
||||
using (var cmd = new NpgsqlCommand($"SELECT * FROM "+tableName+" WHERE projekt_id = @1", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", id);
|
||||
using var reader = await cmd.ExecuteReaderAsync();
|
||||
@@ -99,7 +99,7 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
|
||||
public async Task<Projekt> Update(Projekt entity)
|
||||
{
|
||||
string command = "UPDATE "+tableName+" SET \"Projektname\"=@1, \"Erstelldatum\"=@2, \"Strasse\"=@3, \"Ort\"=@4, \"ExportType\"=@5, \"Kodierungssystem\"=@6 WHERE \"Id\" = @8";
|
||||
string command = "UPDATE "+tableName+" SET projektname=@1, erstelldatum=@2, strasse=@3, ort=@4, exporttype=@5, kodierungssystem=@6 WHERE projekt_id = @8";
|
||||
using (var cmd = new NpgsqlCommand(command, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", entity.Projektname);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user