change dao
This commit is contained in:
parent
f05c4ca34c
commit
684a1ad692
@ -9,6 +9,10 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.11">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.11" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.11" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ public class ItemDao
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
public virtual CategoryDao? Category { get; set; }
|
public virtual CategoryDao? Category { get; set; }
|
||||||
public virtual RateDao? Rate { get; set; }
|
public virtual RateDao? Rate { get; set; }
|
||||||
|
33
LootBoxSimulator/Models/DAO/RemoteDatabaseContext.cs
Normal file
33
LootBoxSimulator/Models/DAO/RemoteDatabaseContext.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace LootBoxSimulator.Models.DAO;
|
||||||
|
|
||||||
|
public class RemoteDatabaseContext : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Username=postgres;Password=123");
|
||||||
|
}
|
||||||
|
public DbSet<ItemDao> Items { get; set; }
|
||||||
|
public DbSet<RateDao> Rates { get; set; }
|
||||||
|
public DbSet<CategoryDao> Categories { get; set; }
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
base.OnModelCreating(modelBuilder);
|
||||||
|
modelBuilder.Entity<ItemDao>()
|
||||||
|
.HasKey(x => x.Id);
|
||||||
|
modelBuilder.Entity<ItemDao>()
|
||||||
|
.Property(x => x.Id)
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
modelBuilder.Entity<RateDao>()
|
||||||
|
.HasKey(x => x.Id);
|
||||||
|
modelBuilder.Entity<CategoryDao>()
|
||||||
|
.Property(x => x.Id)
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
modelBuilder.Entity<CategoryDao>()
|
||||||
|
.HasKey(x => x.Id);
|
||||||
|
modelBuilder.Entity<RateDao>()
|
||||||
|
.Property(x => x.Id)
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1,8 @@
|
|||||||
|
using LootBoxSimulator.Models.DAO;
|
||||||
|
|
||||||
|
RemoteDatabaseContext db = new RemoteDatabaseContext();
|
||||||
|
|
||||||
|
foreach (var result in db.Categories)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{result.Id} | {result.Name}");
|
||||||
|
}
|
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("LootBoxSimulator")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("LootBoxSimulator")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f05c4ca34c40f604537abb997bf99aa3ec9ee1e5")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("LootBoxSimulator")]
|
[assembly: System.Reflection.AssemblyProductAttribute("LootBoxSimulator")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("LootBoxSimulator")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("LootBoxSimulator")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -14,5 +14,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
<Import Project="$(NuGetPackageRoot)microsoft.entityframeworkcore/8.0.11/buildTransitive/net8.0/Microsoft.EntityFrameworkCore.props" Condition="Exists('$(NuGetPackageRoot)microsoft.entityframeworkcore/8.0.11/buildTransitive/net8.0/Microsoft.EntityFrameworkCore.props')" />
|
<Import Project="$(NuGetPackageRoot)microsoft.entityframeworkcore/8.0.11/buildTransitive/net8.0/Microsoft.EntityFrameworkCore.props" Condition="Exists('$(NuGetPackageRoot)microsoft.entityframeworkcore/8.0.11/buildTransitive/net8.0/Microsoft.EntityFrameworkCore.props')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)microsoft.entityframeworkcore.design/8.0.11/build/net8.0/Microsoft.EntityFrameworkCore.Design.props" Condition="Exists('$(NuGetPackageRoot)microsoft.entityframeworkcore.design/8.0.11/build/net8.0/Microsoft.EntityFrameworkCore.Design.props')" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<PkgMicrosoft_CodeAnalysis_Analyzers Condition=" '$(PkgMicrosoft_CodeAnalysis_Analyzers)' == '' ">/home/laptop/.nuget/packages/microsoft.codeanalysis.analyzers/3.3.3</PkgMicrosoft_CodeAnalysis_Analyzers>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user