2024-02-01 13:48:38 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Microsoft.Extensions.Configuration.Json;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2024-03-05 19:49:58 +08:00
|
|
|
|
using Parking_space_WebAPI.Models;
|
|
|
|
|
using Parking_space_WebAPI.Entities;
|
2024-02-01 13:48:38 +08:00
|
|
|
|
|
|
|
|
|
|
2024-03-05 19:49:58 +08:00
|
|
|
|
namespace Parking_space_WebAPI.Services
|
2024-02-01 13:48:38 +08:00
|
|
|
|
{
|
|
|
|
|
public class SqlContext : DbContext
|
|
|
|
|
{
|
|
|
|
|
public SqlContext(DbContextOptions<SqlContext> options) : base(options)
|
|
|
|
|
{
|
|
|
|
|
//連接PostgreSQL
|
|
|
|
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
|
|
|
|
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//public DbSet<E_table_v> e_table_v { get; set; } = null!;
|
|
|
|
|
public DbSet<User> parking_spaces_user { get; set; } = null!;
|
|
|
|
|
public DbSet<Parking_spaces_total_table> parking_spaces_total_table { get; set; } = null!; //<Parking_spaces_total_table> Model名稱 parking_spaces_total_table SQL名稱
|
|
|
|
|
public DbSet<Parking_spaces_violation_total_table> parking_spaces_violation_total_table { get; set; } = null!; //<Parking_spaces_total_table> Model名稱 parking_spaces_total_table SQL名稱
|
|
|
|
|
public DbSet<Parking_spaces_instant> parking_spaces_instant { get; set; } = null!; //<Parking_spaces_instant> Model名稱 parking_spaces_instant SQL名稱
|
|
|
|
|
public DbSet<Parking_spaces_history> parking_spaces_history { get; set; } = null!; //<Parking_spaces_history> Model名稱 parking_spaces_history SQL名稱
|
|
|
|
|
public DbSet<Parking_spaces_lcd_instand> parking_spaces_lcd_instand { get; set; } = null!; //<Parking_spaces_lcd_instand> Model名稱 parking_spaces_lcd_instand SQL名稱
|
|
|
|
|
|
|
|
|
|
public DbSet<Parking_spaces_cam> parking_spaces_cam { get; set; } = null!;
|
|
|
|
|
public DbSet<Violation_car_table> violation_car_table { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
//cam_roi
|
|
|
|
|
public DbSet<Parking_spaces_roi> parking_spaces_roi { get; set; } = null!;
|
|
|
|
|
public DbSet<Parking_spaces_roi_pass> parking_spaces_roi_pass { get; set; } = null!;
|
|
|
|
|
public DbSet<Parking_spaces_roi_violation> parking_spaces_roi_violation { get; set; } = null!;
|
|
|
|
|
public DbSet<Parking_spaces_roi_car_num_check> parking_spaces_roi_car_num_check { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
// cam_ptz
|
|
|
|
|
public DbSet<Parking_spaces_cam_ptz> parking_spaces_cam_ptz { get; set; } = null!;
|
|
|
|
|
public DbSet<Parking_spaces_cam_ptz_car_num_check> parking_spaces_cam_ptz_car_num_check { get; set; } = null!;
|
|
|
|
|
public DbSet<Parking_spaces_cam_ptz_pass> parking_spaces_cam_ptz_pass { get; set; } = null!;
|
|
|
|
|
public DbSet<Parking_spaces_cam_ptz_violation> parking_spaces_cam_ptz_violation { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
// 演算法
|
|
|
|
|
public DbSet<Parking_space_algorithm> parking_space_algorithm { get; set; } = null!;
|
|
|
|
|
|
2024-02-04 19:20:00 +08:00
|
|
|
|
//大門口
|
|
|
|
|
public DbSet<Yuntech_in_car_table> yuntech_in_car_table { get; set; } = null!;
|
|
|
|
|
|
2024-02-14 22:08:27 +08:00
|
|
|
|
//雲科校內相機
|
|
|
|
|
public DbSet<Yuntech_cam_total_table> yuntech_cam_total_table { get; set; } = null!;
|
|
|
|
|
public DbSet<Yuntech_cam> yuntech_cam { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
|
2024-02-01 13:48:38 +08:00
|
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
base.OnModelCreating(builder);
|
|
|
|
|
builder.Entity<User>().HasKey(o => new { o.id }); //Primary Key
|
|
|
|
|
builder.Entity<Parking_spaces_total_table>().HasKey(o => new { o.parking_spaces_name }); //Primary Key
|
|
|
|
|
builder.Entity<Parking_spaces_violation_total_table>().HasKey(o => new { o.parking_spaces_violation_name }); //Primary Key
|
|
|
|
|
builder.Entity<Parking_spaces_lcd_instand>().HasKey(o => new { o.lcd_ip }); //Primary Key
|
|
|
|
|
builder.Entity<Parking_spaces_instant>().HasKey(o => new { o.parking_spaces_name ,o.data_create_time }); //Primary Key
|
|
|
|
|
builder.Entity<Parking_spaces_history>().HasKey(o => new { o.parking_spaces_name, o.license_plate_number, o.data_create_time }); //Primary Key
|
|
|
|
|
builder.Entity<Violation_car_table>().HasKey(o => new { o.violation_location_name, o.license_plate_number, o.create_data_time }); //Primary Key
|
|
|
|
|
|
|
|
|
|
builder.Entity<Parking_spaces_roi>().HasKey(o => new { o.parking_spaces_name, o.data_create_time }); //Primary Key
|
|
|
|
|
builder.Entity<Parking_spaces_roi_pass>().HasKey(o => new { o.parking_spaces_name, o.data_create_time }); //Primary Key
|
|
|
|
|
builder.Entity<Parking_spaces_roi_violation>().HasKey(o => new { o.parking_spaces_name, o.data_create_time }); //Primary Key
|
|
|
|
|
builder.Entity<Parking_spaces_roi_car_num_check>().HasKey(o => new { o.parking_spaces_name, o.data_create_time }); //Primary Key
|
|
|
|
|
|
|
|
|
|
builder.Entity<Parking_spaces_cam>().HasKey(o => new { o.parking_spaces_name }); //Primary Key
|
|
|
|
|
builder.Entity<Parking_spaces_cam_ptz>().HasKey(o => new { o.rtsp_url }); //Primary Key
|
|
|
|
|
builder.Entity<Parking_spaces_cam_ptz_car_num_check>().HasKey(o => new { o.rtsp_url,o.create_data_time }); //Primary Key
|
|
|
|
|
builder.Entity<Parking_spaces_cam_ptz_pass>().HasKey(o => new { o.rtsp_url, o.create_data_time }); //Primary Key
|
|
|
|
|
builder.Entity<Parking_spaces_cam_ptz_violation>().HasKey(o => new { o.rtsp_url, o.create_data_time }); //Primary Key
|
|
|
|
|
|
|
|
|
|
builder.Entity<Parking_space_algorithm>().HasKey(o => new { o.algorithm_serial_num }); //Primary Key
|
|
|
|
|
|
2024-02-04 19:20:00 +08:00
|
|
|
|
builder.Entity<Yuntech_in_car_table>().HasKey(o => new { o.in_time }); //Primary Key
|
2024-02-14 22:08:27 +08:00
|
|
|
|
|
|
|
|
|
builder.Entity<Yuntech_cam_total_table>().HasKey(o => new { o.location_name }); //Primary Key
|
|
|
|
|
builder.Entity<Yuntech_cam>().HasKey(o => new { o.ip }); //Primary Key
|
2024-02-01 13:48:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|