CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 06:11:56 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=f51194e3147d1e46649ba5d4eea8af6341ef5216caf32238332eb0f596a94ce8a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22M7rbW2LF4kzRJ_06u01AayecHWE8N__5%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d471566f688e4d-BLR
TPC Example - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.EntityFrameworkCore;
- using System.ComponentModel.DataAnnotations;
- using System.ComponentModel.DataAnnotations.Schema;
- namespace EFCore6Tests.TPC
- {
- [Table("Client", Schema = "TPC")]
- public class Client
- {
- [Key]
- public int ClientId { get; protected set; }
- public string Name { get; set; }
- public virtual ClientAddress ClientAddress { get; set; }
- #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- public Client() { }
- #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- }
- [Table("ClientAddress", Schema = "TPC")]
- public class ClientAddress : IAddress
- {
- [Key]
- public int ClientAddressId { get; protected set; }
- public string Name { get; set; }
- public string? UnitNum { get; set; }
- public string StreetNum { get; set; }
- public string StreetName { get; set; }
- public string StreetType { get; set; }
- public int SuburbId { get; set; }
- public string City { get; set; }
- int IAddress.Id { get => ClientAddressId; }
- string IAddress.AddressType
- {
- get => typeof(ClientAddress).Name;
- }
- public Client? Client { get; set; }
- #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- public ClientAddress() { } // make protected if only for EF to use.
- #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- public ClientAddress(string name, string? unitNum, string streetNum, string streetName, string streetType, int suburbId, string city)
- {
- Name = name;
- UnitNum = unitNum;
- StreetNum = streetNum;
- StreetName = streetName;
- StreetType = streetType;
- SuburbId = suburbId;
- City = city;
- }
- }
- public interface IAddress
- {
- public int Id { get; }
- string AddressType { get; }
- string Name { get; }
- string? UnitNum { get; }
- string StreetNum { get; }
- string StreetName { get; }
- string StreetType { get; }
- int SuburbId { get; }
- string City { get; }
- }
- public class TPCDbContext : DbContext
- {
- public DbSet<Client> Clients { get; set; }
- public DbSet<ClientAddress> ClientAddresses { get; set; }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- optionsBuilder.UseSqlServer(@"Data Source=Machine\SQLEXPRESS;Initial Catalog=Inheritance;Trusted_Connection=Yes;MultipleActiveResultSets=True;TrustServerCertificate=True");
- base.OnConfiguring(optionsBuilder);
- }
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- modelBuilder.Entity<Client>()
- .HasOne(x => x.ClientAddress)
- .WithOne(x => x.Client)
- .HasForeignKey<Client>("ClientAddressId");
- }
- }
- }
- using EFCore6Tests.TPC;
- using Microsoft.EntityFrameworkCore;
- using NUnit.Framework;
- namespace EFCore6Tests
- {
- [TestFixture]
- public class TPCTests
- {
- [Test]
- public void CreateTest()
- {
- using var context = new TPCDbContext();
- var client = new Client
- {
- Name = "Test1",
- ClientAddress = new ClientAddress { Name = "Test", StreetNum = "1a", StreetName = "Pelican", SuburbId = 2, StreetType = "Drive", City = "Bay City" }
- };
- context.Clients.Add(client);
- context.SaveChanges();
- }
- [Test]
- public void ReadTest()
- {
- using var context = new TPCDbContext();
- var clients = context.Clients.Include(x => x.ClientAddress).ToList();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ A
JavaScript | 6 sec ago | 0.25 KB
-
⭐✅ Swapzone Glitch ✅ Working ⭐⭐ L
JavaScript | 14 sec ago | 0.25 KB
-
✅ Make $2500 in 20 minutes⭐⭐⭐ H
JavaScript | 23 sec ago | 0.25 KB
-
📌 Swapzone +37% glitch ⭐ 5
JavaScript | 31 sec ago | 0.25 KB
-
✅⭐ Make huge profits on trading ⭐⭐ E
JavaScript | 40 sec ago | 0.25 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 50 sec ago | 0.25 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ Y
JavaScript | 59 sec ago | 0.25 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ A
JavaScript | 1 min ago | 0.25 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand