using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
string InfoCard(EntityType entityType, string entityId)
var context = new MarketContext();
var agent = context.Agents.Find(entityId);
infoCard = new string($"Agent: {agent.Name}\r\n" +
$"Phone: {agent.Phone}\r\n" +
$"Email: {agent.Email}");
var office = context.Offices.Find(entityId);
infoCard = new string($"Office: {office.Name}\r\n" +
$"Address: {office.Address}\r\n" +
$"Phone: {office.Phone}");
var firm = context.Firms.Find(entityId);
infoCard = new string($"firm: {firm.Name}\r\n" +
$"Address: {firm.Address}\r\n" +
List<string> Top5(EntityType entityType)
var context = new MarketContext();
var top5List = new List<string>();
top5List = (List<string>)context.Agents
.OrderBy(a => a.Sales).Take(5).Select(a => a.Name);
top5List = (List<string>)context.Offices
.OrderBy(a => a.Sales).Take(5).Select(a => a.Name);
top5List = (List<string>)context.Firms
.OrderBy(a => a.Sales).Take(5).Select(a => a.Name);
public class MarketContext : DbContext
public DbSet<Agent> Agents { get; set; }
public DbSet<Office> Offices { get; set; }
public DbSet<Firm> Firms { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlServer("Data Source=Market.db");
public int AgentId { get; set; }
public string Name { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public string OfficeId { get; set; }
public decimal Sales { get; set; }
public int OfficeId { get; set; }
public string Name { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public string FirmId { get; set; }
public decimal Sales { get; set; }
public List<Agent> Agents { get; } = new List<Agent>();
public int FirmId { get; set; }
public string Name { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public decimal Sales { get; set; }
public List<Agent> Offices { get; } = new List<Agent>();