diff --git a/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp.sln b/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp.sln new file mode 100644 index 0000000..98f932e --- /dev/null +++ b/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvaloniaPostrgresApp", "AvaloniaPostrgresApp\AvaloniaPostrgresApp.csproj", "{2D67BF53-BE3F-4118-8095-57A478E04588}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2D67BF53-BE3F-4118-8095-57A478E04588}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D67BF53-BE3F-4118-8095-57A478E04588}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D67BF53-BE3F-4118-8095-57A478E04588}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D67BF53-BE3F-4118-8095-57A478E04588}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/App.axaml b/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/App.axaml new file mode 100644 index 0000000..4c787c3 --- /dev/null +++ b/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/App.axaml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/App.axaml.cs b/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/App.axaml.cs new file mode 100644 index 0000000..b6ee5c4 --- /dev/null +++ b/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/App.axaml.cs @@ -0,0 +1,23 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; + +namespace AvaloniaPostrgresApp; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow(); + } + + base.OnFrameworkInitializationCompleted(); + } +} \ No newline at end of file diff --git a/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/AppDbContext.cs b/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/AppDbContext.cs new file mode 100644 index 0000000..a9761e3 --- /dev/null +++ b/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/AppDbContext.cs @@ -0,0 +1,31 @@ +using AvaloniaPostrgresApp.Models; +using Microsoft.EntityFrameworkCore; +namespace AvaloniaPostrgresApp; + +public class AppDbContext : DbContext +{ + public DbSet Users { get; set; } = null!; + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + + string connectionString = "Host=127.0.0.1;Port=5432;Database=postgres;Username=postgres;Password=mysecretpassword;Timeout=15;Command Timeout=15;Trust Server Certificate=true;SSL Mode=Prefer"; + optionsBuilder.UseNpgsql(connectionString); + } + + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + modelBuilder.Entity().ToTable("UserInfo"); + + modelBuilder.Entity().Property(u => u.Id).HasColumnName("id"); + modelBuilder.Entity().Property(u => u.Fio).HasColumnName("fio"); + modelBuilder.Entity().Property(u => u.Login).HasColumnName("login"); + modelBuilder.Entity().Property(u => u.Password).HasColumnName("password"); + modelBuilder.Entity().Property(u => u.RoleId).HasColumnName("role_id"); + + modelBuilder.Entity().Ignore(u => u.Orders); + modelBuilder.Entity().Ignore(u => u.Role); + } +} \ No newline at end of file diff --git a/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/AvaloniaPostrgresApp.csproj b/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/AvaloniaPostrgresApp.csproj new file mode 100644 index 0000000..c4f57af --- /dev/null +++ b/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/AvaloniaPostrgresApp.csproj @@ -0,0 +1,24 @@ + + + WinExe + net10.0 + enable + app.manifest + + + + + + + + + None + All + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/MainWindow.axaml b/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/MainWindow.axaml new file mode 100644 index 0000000..e12e618 --- /dev/null +++ b/works/Demo/AvaloniaPostrgresApp/AvaloniaPostrgresApp/MainWindow.axaml @@ -0,0 +1,30 @@ + + + + + + + + + + +