Skip to content

Instantly share code, notes, and snippets.

View Ruthenus's full-sized avatar

Ruslan Kachurovskyi Ruthenus

  • Odesa, Ukraine
View GitHub Profile
@sunmeat
sunmeat / Program.cs
Last active March 25, 2026 22:52
список таблиць певної БД, список назв полів з типами
using Microsoft.Data.SqlClient;
class Program
{
static void Main()
{
Console.Title = "Список таблиць БД";
Console.OutputEncoding = System.Text.Encoding.UTF8;
// MARS - Multiple Active Result Sets !!! MultipleActiveResultSets=True; !!!
@sunmeat
sunmeat / Program.cs
Last active March 26, 2026 22:29
code first - EF Core - one table (SQL Server)
using Microsoft.EntityFrameworkCore;
namespace EF_Core___Code_First__1_Table
{
public class User
{
public int Id { get; set; } // первинний ключ
public string? Name { get; set; } // інші поля
public int Age { get; set; }
}
@sunmeat
sunmeat / different files.cs
Last active June 3, 2026 19:12
code first: one-to-many example + migrations
// початкова версія: https://github.com/sunmeat/efcore_codefirst_ensurecreated
// ApplicationDbContext.cs:
using EFCoreCodeFirst.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace EFCoreCodeFirst
{
@sunmeat
sunmeat / different files.cs
Last active June 4, 2026 20:08
code first: many-to-many example
AppDbContext.cs:
using EFCoreCodeFirst.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace EFCoreCodeFirst
{
public class AppDbContext : DbContext
{
@sunmeat
sunmeat / different filest.cs
Last active June 13, 2026 12:23
автоматично створена проміжкова таблиця
AppDbContext.cs:
using EFCoreCodeFirst.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace EFCoreCodeFirst
{
public class AppDbContext : DbContext
{
@sunmeat
sunmeat / different files.cs
Last active June 13, 2026 13:13
CRUD operations entity framework core code first many to many example
... контекст ...
... моделі ...
=========================================================================================================
Repositories / PersonRepository.cs:
public class PersonRepository
{
@sunmeat
sunmeat / Library.cs
Created February 16, 2025 14:50
DLL side
using System.Xml.Serialization;
using System.Reflection;
public interface IFileHandler
{
void WriteToFile<T>(string filePath, T data);
T ReadFromFile<T>(string filePath);
void UpdateFile<T>(string filePath, T data);
}
@sunmeat
sunmeat / Program.cs
Last active December 24, 2025 18:12
DLL use
namespace UseDll
{
public class Person
{
public string? Name { get; set; }
public int Age { get; set; }
}
internal class Program
{
@sunmeat
sunmeat / Program.cs
Last active February 19, 2026 17:03
DLL runtime
// https://learn.microsoft.com/uk-ua/dotnet/api/system.runtime.loader.assemblyloadcontext?view=net-9.0
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Loader;
using System.Text;
namespace UseDll
{
public class Person
@sunmeat
sunmeat / .csproj
Last active December 24, 2025 18:30
nuget project properties
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- метадані для NuGet пакету -->
<PackageId>com.sunmeat.mylibrary</PackageId> <!-- тут вкажіть свій УНІКАЛЬНИЙ ID пакету -->
<Version>1.0.0</Version> <!-- вкажіть версію пакету -->