commit 95f3858755ffae4789e12946738e7950301d2ec8 Author: Zhiltsov Alexander Date: Mon Jul 20 18:41:53 2026 +1000 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd42ee3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bin/ +obj/ diff --git a/helloapp/HelloappContext.cs b/helloapp/HelloappContext.cs new file mode 100644 index 0000000..81e4a4c --- /dev/null +++ b/helloapp/HelloappContext.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; + +namespace helloapp; + +public partial class HelloappContext : DbContext +{ + public HelloappContext() + { + } + + public HelloappContext(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet Users { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) +#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263. + => optionsBuilder.UseSqlite("Data Source=./helloapp.db"); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/helloapp/Program.cs b/helloapp/Program.cs new file mode 100644 index 0000000..1973097 --- /dev/null +++ b/helloapp/Program.cs @@ -0,0 +1,12 @@ +using helloapp; + +using (HelloappContext db = new HelloappContext()) +{ + // получаем объекты из бд и выводим на консоль + var users = db.Users.ToList(); + Console.WriteLine("Список объектов:"); + foreach (User u in users) + { + Console.WriteLine($"{u.Id}.{u.Name} - {u.Age}"); + } +} \ No newline at end of file diff --git a/helloapp/User.cs b/helloapp/User.cs new file mode 100644 index 0000000..0630e50 --- /dev/null +++ b/helloapp/User.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace helloapp; + +public partial class User +{ + public int Id { get; set; } + + public string? Name { get; set; } + + public int Age { get; set; } +} diff --git a/helloapp/helloapp.csproj b/helloapp/helloapp.csproj new file mode 100644 index 0000000..5383858 --- /dev/null +++ b/helloapp/helloapp.csproj @@ -0,0 +1,18 @@ + + + + Exe + net10.0 + enable + enable + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + diff --git a/helloapp/helloapp.db b/helloapp/helloapp.db new file mode 100644 index 0000000..5eaebf6 Binary files /dev/null and b/helloapp/helloapp.db differ