Införande av repository method

This commit is contained in:
2024-05-22 11:10:37 +02:00
parent 673387215d
commit c7d4307f47
23 changed files with 541 additions and 17 deletions

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Accounting.Models\Accounting.Models.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,13 @@
using Accounting.Models;
using Microsoft.EntityFrameworkCore;
namespace Accounting.DAL;
public class DataContext : DbContext
{
public DataContext(DbContextOptions options) : base(options)
{
}
public DbSet<AccountRecord> AccountRecords { get; set; }
}

View File

@ -0,0 +1,64 @@
// <auto-generated />
using System;
using Accounting.DAL;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Accounting.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20240429161713_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Accounting.Entities.AccountRecord", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Avisering")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Belopp")
.HasColumnType("float");
b.Property<DateTime>("BetalDatum")
.HasColumnType("datetime2");
b.Property<string>("Konto")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Mottagare")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("Stored")
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("AccountRecords");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,40 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Accounting.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AccountRecords",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
BetalDatum = table.Column<DateTime>(type: "datetime2", nullable: false),
Mottagare = table.Column<string>(type: "nvarchar(max)", nullable: false),
Konto = table.Column<string>(type: "nvarchar(max)", nullable: false),
Belopp = table.Column<double>(type: "float", nullable: false),
Avisering = table.Column<string>(type: "nvarchar(max)", nullable: false),
Stored = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AccountRecords", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AccountRecords");
}
}
}

View File

@ -0,0 +1,61 @@
// <auto-generated />
using System;
using Accounting.DAL;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Accounting.Migrations
{
[DbContext(typeof(DataContext))]
partial class DataContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Accounting.Entities.AccountRecord", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Avisering")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Belopp")
.HasColumnType("float");
b.Property<DateTime>("BetalDatum")
.HasColumnType("datetime2");
b.Property<string>("Konto")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Mottagare")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("Stored")
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("AccountRecords");
});
#pragma warning restore 612, 618
}
}
}