init efcore

This commit is contained in:
bob
2026-05-29 12:21:42 -05:00
commit 3d3a5c2a5e
28 changed files with 2071 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
using BlueLaminate.EFCore.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace BlueLaminate.EFCore.Configurations;
public class InventoryItemConfiguration : IEntityTypeConfiguration<InventoryItem>
{
public void Configure(EntityTypeBuilder<InventoryItem> entity)
{
entity.HasIndex(e => e.AssetId);
entity.HasOne(e => e.User)
.WithMany(u => u.InventoryItems)
.HasForeignKey(e => e.UserId);
entity.HasOne(e => e.SkinInstance)
.WithMany(i => i.InventoryItems)
.HasForeignKey(e => e.SkinInstanceId);
}
}

View File

@@ -0,0 +1,24 @@
using BlueLaminate.EFCore.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace BlueLaminate.EFCore.Configurations;
public class PriceHistoryConfiguration : IEntityTypeConfiguration<PriceHistory>
{
public void Configure(EntityTypeBuilder<PriceHistory> entity)
{
entity.Property(e => e.Price).HasPrecision(18, 2);
entity.HasIndex(e => new { e.SkinId, e.ConditionId, e.RecordedAt });
entity.HasOne(e => e.Skin)
.WithMany(s => s.PriceHistories)
.HasForeignKey(e => e.SkinId);
entity.HasOne(e => e.Condition)
.WithMany(c => c.PriceHistories)
.HasForeignKey(e => e.ConditionId)
.OnDelete(DeleteBehavior.Restrict);
}
}

View File

@@ -0,0 +1,18 @@
using BlueLaminate.EFCore.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace BlueLaminate.EFCore.Configurations;
public class SkinConditionConfiguration : IEntityTypeConfiguration<SkinCondition>
{
public void Configure(EntityTypeBuilder<SkinCondition> entity)
{
entity.Property(e => e.MinFloat).HasColumnType("numeric(10,9)");
entity.Property(e => e.MaxFloat).HasColumnType("numeric(10,9)");
entity.HasOne(e => e.Skin)
.WithMany(s => s.Conditions)
.HasForeignKey(e => e.SkinId);
}
}

View File

@@ -0,0 +1,27 @@
using BlueLaminate.EFCore.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace BlueLaminate.EFCore.Configurations;
public class SkinConfiguration : IEntityTypeConfiguration<Skin>
{
public void Configure(EntityTypeBuilder<Skin> entity)
{
entity.Property(e => e.FloatMin)
.HasColumnType("numeric(10,9)")
.HasDefaultValue(0.0m);
entity.Property(e => e.FloatMax)
.HasColumnType("numeric(10,9)")
.HasDefaultValue(1.0m);
entity.Property(e => e.TrueFloat)
.HasComputedColumnSql("float_min = 0.0 AND float_max = 1.0", stored: true);
entity.HasIndex(e => e.TrueFloat);
entity.HasOne(e => e.Weapon)
.WithMany(w => w.Skins)
.HasForeignKey(e => e.WeaponId);
}
}

View File

@@ -0,0 +1,26 @@
using BlueLaminate.EFCore.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace BlueLaminate.EFCore.Configurations;
public class SkinInstanceConfiguration : IEntityTypeConfiguration<SkinInstance>
{
public void Configure(EntityTypeBuilder<SkinInstance> entity)
{
entity.Property(e => e.FloatValue).HasColumnType("numeric(10,9)");
// Primary lookup key for trade fingerprinting.
entity.HasIndex(e => e.FloatValue);
entity.HasIndex(e => e.PaintSeed);
entity.HasOne(e => e.Skin)
.WithMany(s => s.Instances)
.HasForeignKey(e => e.SkinId);
entity.HasOne(e => e.Condition)
.WithMany(c => c.Instances)
.HasForeignKey(e => e.ConditionId)
.OnDelete(DeleteBehavior.Restrict);
}
}

View File

@@ -0,0 +1,13 @@
using BlueLaminate.EFCore.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace BlueLaminate.EFCore.Configurations;
public class SteamUserConfiguration : IEntityTypeConfiguration<SteamUser>
{
public void Configure(EntityTypeBuilder<SteamUser> entity)
{
entity.HasIndex(e => e.SteamId).IsUnique();
}
}

View File

@@ -0,0 +1,21 @@
using BlueLaminate.EFCore.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace BlueLaminate.EFCore.Configurations;
public class TradeConfiguration : IEntityTypeConfiguration<Trade>
{
public void Configure(EntityTypeBuilder<Trade> entity)
{
entity.HasOne(e => e.FromUser)
.WithMany(u => u.TradesSent)
.HasForeignKey(e => e.FromUserId)
.OnDelete(DeleteBehavior.Restrict);
entity.HasOne(e => e.ToUser)
.WithMany(u => u.TradesReceived)
.HasForeignKey(e => e.ToUserId)
.OnDelete(DeleteBehavior.Restrict);
}
}

View File

@@ -0,0 +1,19 @@
using BlueLaminate.EFCore.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace BlueLaminate.EFCore.Configurations;
public class TradeItemConfiguration : IEntityTypeConfiguration<TradeItem>
{
public void Configure(EntityTypeBuilder<TradeItem> entity)
{
entity.HasOne(e => e.Trade)
.WithMany(t => t.TradeItems)
.HasForeignKey(e => e.TradeId);
entity.HasOne(e => e.InventoryItem)
.WithMany(i => i.TradeItems)
.HasForeignKey(e => e.InventoryItemId);
}
}